So I created I plist file that get a list of all libs licenses on my podfile (following this tutorial: https://johncodeos.com/easy-way-to-list-third-party-libraries-licenses-in-your-ios-app/)
But now how can I get the content of this file? Every example that I used comes with a file path nil. What am I doing wrong?
Example code:
let path = Bundle.path(forResource: "Acknowledgements", ofType: "plist", inDirectory: "Licenses")
I would like to get title and footerText of every Item in my PreferenceSpecifiers. How could I do that?
PS.: I’ve never work with plist/bundle.setting files before, so forgive if I’m asking something dumb. I’ve read about but it/s still cloudy to me
2
Answers
You can use the function
url(forResource:withExtension:)
instead of the path. You can use this function (replace MyPlistFile.plist with the name of your file):To get a nested dictionary, you need to change the type, from
String
to a dictionary type, like[String: String]
, then read inside that dictionary.You can try this code:
First of all you should search path for existing plist file and then convert its content to the Dictionary for access to values by string keys.
Be careful about force unwrap (
!
)