tags:

views:

281

answers:

2

Hi

I am building an iPhone app that has some default data inside it via a property list. This data is the source for my Model. What is the best way to manage this data so the user can read (and in a couple of cases write) data from this plist?

I currently am subclassing NSObject and mapping the plist data to properties in that object, with methods to read/write data to the object. I have read about the NSCoding protocol and NSCoder but am not sure how to implement this in my custom class.

Any help will be appreciated.

Thanks

A: 

Seems the answer is in this link:

http://mojomonkeycoding.com/tag/nscoding/

I guess you do not worry about super being initWithCoder in these cases.

mga
This link seems to be better:http://cocoaheads.byu.edu/wiki/nscoding
mga
A: 

If you really want to keep the data in a plist then you can use NSString:propertyList. It'll take the property list and parse it into the necessary structures for you. You can then use NSPropertyListSerialization to write it back out.

Frankly, what you're doing is easier unless you have a ton of different entities to track. There are a lot of ways to simply load and save data, if that's all you're interested in. Besides NSCoder (which is a lot of boilerplate code for my taste) you could use CoreData and not worry about the serialization process at all--CoreData manages it all for you semi-automagically.

The app loads 7 name/value pairs and an array of dictionaries (say, a list of people each with his/her data). I want to use this data in different views throughout the app.
mga
Plists are great for config kind of data updated infrequently. If you have a bunch of data in there or more frequent updates, you should probably use CoreData.
Kendall Helmstetter Gelner
it is mostly a read-only list of values and 4 name/value pairs for persistent app state
mga