It's a bit confusing, but NSCoding and the NSArray and NSDictionary property list methods are two separate things.
You have two choices:
- Use NSCoding. Here's an answer which shows how to correctly get the coding methods called on the contents of the array.
- Use
-[NSArray writeToFile:atomically:]
. Instead of implementing-initWithCoder:
and-decodeWithCoder
, create two methods of your own:-dictionaryValue
and-initWithDictionary:
. To write, iterate through the array of model objects, build a new array of dictionaries, and invoke-writeToFile:atomically:
on that. To read, invoke one of the NSArray reading methods, take the dictionaries it contains, and invoke-initWithDictionary:
with each one.
If you want a human-readable plist, the second option is a good choice.