• 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
Accessing NSKeyedArchiver's archivedDataWithRootObject by name
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Accessing NSKeyedArchiver's archivedDataWithRootObject by name


  • Subject: Accessing NSKeyedArchiver's archivedDataWithRootObject by name
  • From: "Jim Turner" <email@hidden>
  • Date: Tue, 9 Dec 2008 12:17:56 -0600

I have a situation where I'm archiving an array of objects via
NSKeyedArchiver's archivedDataWithRootObject: and later needing to set
a delegate on the NSKeyedUnarchiver that decodes it.  The
documentation is a bit unclear on how one starts the unarchive process
when a NSKeyedUnarchiver is created on an archive where you don't
know, for certain, the keys it contains.

So my question... is this legitimate?

NSKeyedUnarchiver *_keyedUnarchiver = [[[NSKeyedUnarchiver alloc]
initForReadingWithData:archivedData] autorelease];
[_keyedUnarchiver setDelegate:self];
NSMutableArray *archivedArray = [_keyedUnarchiver decodeObjectForKey:@"root"];
[_keyedUnarchiver finishDecoding];

It works, but I always question things when I hard-code a string for
something.  Will 'root' always be the key that represents the root
object?

If I could do something like [NSKeyedUnarchiver
unarchiveObjectWithData:delegate:], that would be better than perfect.

--
Jim
http://nukethemfromorbit.com
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Accessing NSKeyedArchiver's archivedDataWithRootObject by name
      • From: "Michael Ash" <email@hidden>
  • Prev by Date: Fwd: Text Not Anti-Aliased In NSView
  • Next by Date: Re: performance problem with IORegistryEntryCreateCFProperties
  • Previous by thread: Re: How to launch window of the application on clicking of dock icon?
  • Next by thread: Re: Accessing NSKeyedArchiver's archivedDataWithRootObject by name
  • Index(es):
    • Date
    • Thread