• 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: 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


  • Follow-Ups:
    • Re: NSArchiving and NSUnarchiving multiple objects
      • From: Jason Taylor <email@hidden>
    • Re: NSArchiving and NSUnarchiving multiple objects
      • From: Jason Taylor <email@hidden>
References: 
 >NSArchiving and NSUnarchiving multiple objects (From: Jason Taylor <email@hidden>)

  • Prev by Date: Re: scrollRangeToVisible is slowing me down
  • Next by Date: Re: Custom bindings in a control/cell pair
  • Previous by thread: NSArchiving and NSUnarchiving multiple objects
  • Next by thread: Re: NSArchiving and NSUnarchiving multiple objects
  • Index(es):
    • Date
    • Thread