• 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
Migrating to keyed archiving...?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Migrating to keyed archiving...?


  • Subject: Migrating to keyed archiving...?
  • From: "Ben Kennedy" <email@hidden>
  • Date: Thu, 13 Nov 2003 15:05:30 -0500
  • Organization: Zygoat Creative Technical Services

Hi folks,

I feel like a bit of a dunce here, but I have a fundamental
implementation problem. Thanks to Panther's release, it's now time to
bring my app up to a minimum requirement of Jaguar. :) Accordingly, I'm
migrating all of my objects' archiving to use the keyed archiving mechanism.

The thing I can't figure out is how to alter my code such that it will
properly un-archive both old-school and new-school archive formats.
NSUnarchiver chokes on a file written out with NSKeyedArchiver
(understandably), and NSKeyedUnarchiver balks on old-school files written
out with NSUnarchiver. How do I handle pre-existing old-style files?

This is the hack that I'm now using, which seems to work:

ZDBSong *song;
NSData *d = [NSData dataWithContentsOfFile:filename];
if(!bcmp([d bytes], "\004\013typedstream", 13)) // old-school or new-
school?
song = [NSUnarchiver unarchiveObjectWithData:d]; // oldschool
else song = [NSKeyedArchiver unarchiveObjectWithData:d]; // newschool
[song retain];

This is ugly though. There must be a saner way. What am I missing?
(And please don't tell me I should be declaring a new file type, new file
extension, etc. for the new-school format...)

-ben

--
Ben Kennedy, chief magician
zygoat creative technical services
613-228-3392 | 1-866-466-4628
http://www.zygoat.ca
_______________________________________________
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: Migrating to keyed archiving...?
      • From: Drew McCormack <email@hidden>
  • Prev by Date: Re: Modal Windows in Framework or Bundle?
  • Next by Date: Re: NSTask...Whois
  • Previous by thread: Re: Two dimensional array
  • Next by thread: Re: Migrating to keyed archiving...?
  • Index(es):
    • Date
    • Thread