Is there a better way to serialize an ObjC object than using /NSKeyedArchive?
I need to distribute the object through a C++ std:ostream-like object to put on another computer.
The object has over 122 members of various types... for which wants me to
[coder encodeObject: (id) forKey: @"blah"];
for all of them...
Does anyone have a nice Perl Script that will at least write it out? I don't even know if the objects it contains implement which means this could turn into a huge ugly mess since I can't change the source of the object - I'll have to inherit & add the @interface
to it...
Or am I being dumb? Apple's guide doesn't help me since archiving to XML won't pass nicely though the ostream.
Is there a better way to do this?
-S!
[Edit 1]
So I've looked at NSCoding, and my classes contain generic NSManagedObjects
... which don't conform to <NSCoding>
. I've tried using the Aspect Oriented Programing found [here][2] - but this leads to an infinite recursion at runtime. (at least that's what I assume a call stack of 104795 calls to [id encodeWithCoder:]
are.
Plus, I can't just add <NSCoding>
to the class as I'm loading as its members are objects of an imported framework. I can't just add the protocol to it, which is why I thought the Aspect-Oriented stuff would work.
The last (and terrible) Idea that I have is to subclass every class I need, and implement the protocols there. A huge roadblock I can forsee is if the classes include NSArrays of Classes not exposed in the framework. Then I'm sunk.
Is there a better way to do this? I feel like is a design-time decision, and it's too late now to be adding this capability.
help...
PS
this whole anti-spam thing with limiting links suck. How am I supposed to ask intelligent questions!?
[2]: http:/ /davedelong.com/blog/2009/04/13/aspect-oriented-programming-objective-c#comment-803