I’m replacing an array of NSMutableDictionary objects with an array of custom objects. Each has 15 or so instance variables which need to persist and a couple more which are transient.
I used to read and write these using -initWithContentsOfURL: and -writeToURL:.
What’s the best way to produce the same plist file with the new data structure?
It seems like one approach for saving is to recreate an array of equivalent dictionaries and call -writeToURL:, and vice versa for loading. I wonder if there’s a simple way to do that, or a simpler more direct approach.
I often find that the most expedient way to do this is to create a tree of NSMutableDictionaries from the tree of custom objects and archive it. Obviously this has memory and CPU overhead, and is not strictly as nice as implementing NSCoding as suggested by skidr0w, but as I said, it’s sometimes quicker and easier.