Search code examples
objective-cxcodeplist

Modify plist file in xcode


I developed an application that has a Data.plist file, created by me.

The idea is that by UISwitch Data.plist, which works in the simulator iPhone Xcode, amend does not work on an actual device.

Why is that ? How I can make it work?

Stay tuned to your answer,

Greetings.


Solution

  • Your bundle is read-only on a device.

    The best solution would be to load your plist, save it in a directory of your chosing using the NSFileManager, and then work with the file in that directory.

    Your plist inside the bundle would ONLY be used the very first time your user uses the app, as a blueprint if you will, and then you would work with the .plist you saved in the documents directory.

    This small code snippet will explain how to copy a file from your bundle safely. He uses it with a database but it's really the same for any kind of file.