• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Moving to Keyed Archiving
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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]
initForWritingWithMutableData:data] autorelease];
[archiver encodeObject:someObject];
return data;
}

- (BOOL)loadDataRepresentation:(NSData *)data ofType:(NSString *)aType
{
NSUnarchiver *unarchiver = [[[NSUnarchiver alloc]
initForReadingWithData: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.

  • Follow-Ups:
    • Re: Moving to Keyed Archiving
      • From: Justin Anderson <email@hidden>
  • Prev by Date: Re: My runs through Xcode but not in the Finder...
  • Next by Date: Re: My runs through Xcode but not in the Finder...
  • Previous by thread: Re: My runs through Xcode but not in the Finder...
  • Next by thread: Re: Moving to Keyed Archiving
  • Index(es):
    • Date
    • Thread