When I'm opening up my application for the first time I have an empty plist
that I fill with some values (writeToFile
). I can read from the plist
dynamically and get those values I just put into it. This far this good. Then I close my application and later on I open it again. At this point I want my plist
to contain those values I dynamically wrote to it the previous time I opened the application, but to my disadvantage it's empty.
Is this a normal behaviour? Can I not use the plist
as a "local database" where I save values dynamically, and read them some other time when the application is opened?
Thanks!
Files in "supporting files" are not supposed to be modified.
The files of the supporting files group are (like all other non-code files) copied into the app bundle. Apple says about the app bundle:
If you want to store users preferences, selection, etc. you should create the plist file in the documents directory.
You can get the path to the documents directory using:
If you want to store preferences you may also want to take a look at
NSUserDefaults
.https://developer.apple.com/library/ios/documentation/FileManagement/Conceptual/FileSystemProgrammingGuide/FileSystemOverview/FileSystemOverview.html