• 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
Re: NSArchiving and NSUnarchiving multiple objects
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSArchiving and NSUnarchiving multiple objects


  • Subject: Re: NSArchiving and NSUnarchiving multiple objects
  • From: Jason Taylor <email@hidden>
  • Date: Thu, 24 Feb 2005 22:51:33 -0500

I encoded my two NSMutableArrays of project and groups objects into an NSArray and archived that. Everything works fine now. Thank you so much!

Roarke Lynch wrote:


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
References: 
 >NSArchiving and NSUnarchiving multiple objects (From: Jason Taylor <email@hidden>)
 >Re: NSArchiving and NSUnarchiving multiple objects (From: Roarke Lynch <email@hidden>)

  • Prev by Date: Re: Clicking checkbox in outline view without selecting row
  • Next by Date: Re: Binding name must be same as ivar name?
  • Previous by thread: Re: NSArchiving and NSUnarchiving multiple objects
  • Next by thread: Setting up CoreAudio Package for Audio/Midi Setup icons?
  • Index(es):
    • Date
    • Thread