I've been thinking about how I want to serialize my cocos2d data to a plist. I've worked out what I want to serialize and how, but what I can't decide on is where to implement it.
For example, I intend to store...
NSDictionary (represents a CCScene)
NSArray
NSDictionary (represents CCLayer)
NSArray
NSDictionary (represents CCSprite)
I may end up changing the Dictionaries and Arrays to NSData blobs for speed. But for now I'm going for readability.
What I can't decided is if I want to...
1) Subclass CCScene, CCLayer, and CCSprite and add methods to read and write the data I'm am interested in
2) Create a Singleton object that would read in the plist file and create the Scene, layers and sprites
3) Create Categories for CCScene, CCLayer and CCSprite with methods to read and write the data
The Subclass option has the advantage of being clear which part is working on each object, but I don't see much advantage, since one part won't necessarily work without the others
The Singleton has the advantage of being simple and I would image fairly easy to transition to new versions of cocos2d (very important to me given the development pace of cocos2d). However there wouldn't be any ability to add ivars to the saved objects using this method.
The Categories seems like the worst of the three options to me. I don't see much benefit here and once again the inability to add ivars might be an issue.
I'm very interested on others thoughts and opinions on which would be best.