Moving to Keyed Archiving
Moving to Keyed Archiving
- Subject: Moving to Keyed Archiving
- From: Drew McCormack <email@hidden>
- Date: Tue, 26 Aug 2003 15:57:55 +0200
I would like to move my code over to keyed archiving, but can't seem to
find a good way to upgrade the NSDocument subclass I have such that it
is backwards compatible. In particular, I can't think of a good way to
know whether the data being loaded is in unkeyed or keyed format.
I basically have this:
- (NSData *)dataRepresentationOfType:(NSString *)aType {
NSMutableData *data = [NSMutableData data];
NSArchiver *archiver = [[[NSArchiver alloc]
initForWritingWithMutable
Data:data] autorelease];
[archiver encodeObject:someObject];
return data;
}
- (BOOL)loadDataRepresentation:(NSData *)data ofType:(NSString *)aType
{
NSUnarchiver *unarchiver = [[[NSUnarchiver alloc]
initForReadingWith
Data:data] autorelease];
[someObject release];
someObject = [[unarchiver decodeObject] retain];
return YES;
}
How do I update this to keyed archiving, while maintaining backward
compatibility? In particular, how do I identify what data is being fed
in?
Drew
----------------------------------
Dr. Drew McCormack
Trade Strategist (www.trade-strategist.com)
Stock Market strategy design platform for Mac OS X.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.