• 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: encoding/decoding mutable array
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: encoding/decoding mutable array


  • Subject: Re: encoding/decoding mutable array
  • From: James Bucanek <email@hidden>
  • Date: Fri, 23 Jun 2006 07:15:21 -0700

Ryan Glover wrote on Thursday, June 22, 2006:
>I have a program with a mutable array of objects that I am trying to
>save using a NSKeyedArchiver.  Each object in the array has a number
>of NSString properties that are saved properly (i.e. it works) via
>the encodeWithCoder method in the object class.  However, each object
>also has it's own mutable array of a second type of object.  I have
>implemented encodeWithCoder in the second class as I did in the
>first.  Unfortunately, when I call encodeObject for the second
>mutable array, the encodeWithCoder method for the second class
>appears not to be called as the data is not saved.

To answer your first question, there is nothing special about archiving a collection (NSArray, NSDictionary, etc.); archive it like any other object. All collection classes in Cocoa are NSCoding complient.

The problem is typically that a collection contains one or more objects that doesn't support the NSCoding protocol or doesn't support the specific type (keyed encoding vs. non-keyed encoding) being requested. A class can support one type, both types, or neither. As the collection encodes each member, it runs into an object it can't encode and fails. Look in the output log of the debugger for hints as to which object is causing the problem.

Ensure that *every* object in your collection can be encoded using NSKeyedArchiver and your code should work just fine.

--
James Bucanek
 _______________________________________________
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: 
 >encoding/decoding mutable array (From: Ryan Glover <email@hidden>)

  • Prev by Date: Re: Help with NSArrayController, NSTableView and NSOpenPanel
  • Next by Date: Re: NSOpenPanel isn't listening to me? I told it to only allow .zip and .xml!
  • Previous by thread: encoding/decoding mutable array
  • Next by thread: NSSearchField with bindings: how to get notifications
  • Index(es):
    • Date
    • Thread