I believe something has changed within Swift 2, because no tutorials on how to read and write to property lists seem to be working.
Can anyone whose developing for iOS 9 share their method of R/W to Plists using Swift 2 on Xcode 7?
I believe something has changed within Swift 2, because no tutorials on how to read and write to property lists seem to be working.
Can anyone whose developing for iOS 9 share their method of R/W to Plists using Swift 2 on Xcode 7?
Hopefully this is helpful - without code it is difficult to answer.
The change that tripped me up is that when copying a plist file over to the documents directory the method stringByAppendingPathComponent is no longer available. You have to use NSURL instead.
If you have a preparePlistForUseMethod it should now look like this.
This is working for me on iOS 9 and Xcode 7:
The only thing is that the result is
NSDictionary
and notDictionary
.For reading on a PLIST, I encapsulated the logic in a Singleton. In my case, I want to read the file URLs.plist.
Wherever you need to access one of those URLs, you just:
This works fine with Xcode 7.1 and Swift 2.1.