Re: NSArchiving and NSUnarchiving multiple objects
Re: NSArchiving and NSUnarchiving multiple objects
- Subject: Re: NSArchiving and NSUnarchiving multiple objects
- From: Roarke Lynch <email@hidden>
- Date: Thu, 24 Feb 2005 09:49:34 -0500
On Feb 24, 2005, at 8:42 AM, Jason Taylor wrote:
From my save method:
// This one worked fine by itself
[NSArchiver archiveRootObject:projects toFile:currentDocument];
// This one is causing the problem, although the save executes just
fine without errors
[NSArchiver archiveRootObject:groups toFile:currentDocument];
When you archive a root object to file you aren't appending to the
file you specify, you are overwriting (unless I've read the docs
wrong). If you want to archive a series of objects into one file you've
got two simple options:
1) wrap then with a collection object (i.e. NSArray or NSDictionary)
and then archive that object as the root. Then when you unarchive just
pull out the objects you want and retain them individually.
2) in whatever object class contains projects and groups as instance
variables implement NSCoding and then encode / decode that instance as
the root object.
Roarke Lynch
-------------------------------
email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden