C.Johns
C.Johns

Reputation: 10245

saving values to a plist

I am currently reading though this tutorial here

And in it he seems to be creating a plist file in the resources folder. then in the code he only ever uses that plist once to read from, then dynamically creates a new plist that he uses to store his values and read his value from in the future.

I would like to know if this is good or bad practice? shouldn't he just be using the plist file he created in his resource files?

Upvotes: 0

Views: 129

Answers (3)

jmstone617
jmstone617

Reputation: 5707

Generally, you should just update the values in the existing Plist. You get a Plist for free. It's called NSUserDefaults. If you are just saving/reading a single value, this is the easiest way to do that. In your example, you should check for the existence of said file, and only create it if it doesn't exist.

Upvotes: 0

Noah Witherspoon
Noah Witherspoon

Reputation: 57149

The PLIST that’s included in the app bundle’s resources cannot be written to—iOS’s sandboxing rules prevent apps from modifying themselves. If your app wants to store files, it has to do so in areas that the sandbox allows it access to, such as the Documents directory used in that sample.

Upvotes: 4

SuperRod
SuperRod

Reputation: 557

The problem is that you cannot write to your resources folder. You need to create the file elsewhere if you will be writing to it.

Upvotes: 0

Related Questions