• 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: Using proxy objects with NSMutableArray
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Using proxy objects with NSMutableArray


  • Subject: Re: Using proxy objects with NSMutableArray
  • From: Michael Tyson <email@hidden>
  • Date: Sat, 14 Jul 2007 00:28:48 +1000

Hmm, interestingly, the didDecodeObject method is only called two times as-is - both times with a proxy object.

However, if I just have a 'return object' at the top, it runs three times - two times for the proxy, and the final time with the mutable array.


On 13/07/2007, at 9:49 PM, John Shockey wrote:

On Jul 13, 2007, at 2:50 AM, Michael Tyson wrote:

Hi!

I'm archiving an NSMutableArray object to a file; the array contains some objects of a certain class. The objects in the array are actually stored elsewhere, within their own separate bundles, so I don't want them actually archived - I just want placeholders. So, I'm using a willEncodeObject delegate method to save a proxy object instead, which just contains the identifier of the object being archived. Then, I use a didDecodeObject delegate method to look up the real object, load it, and return it instead of the proxy

However, I'm getting some odd behaviour - I seem to be getting back not the mutable array, but the last object in the array.

The archiving process seems to be fine; if I archive a list with two FLFeed items, and I unarchive with the delegate disabled, I get back the mutable array with two FLFeedProxy items.
However, if I unarchive with the didDecodeObject delegate enabled, I just get a single FLFeed (the last one in the saved list).


Any ideas?

I'm not absolutely certain of the specific symptom, but I do see a definite problem.


You're trying to use "nil" for cases where the real archived object can't be found. But putting "nil" into an NSArray (or NSMutableArray) isn't allowed. The behavior in that case is undefined, and is probably the cause of what you're seeing.

Instead, you could have "unarchiver:didDecodeObject:" return an NSNull object, and then look for and remove those in your "readFromDisk" method. Alternatively, leave the proxy objects alone if you can't find the original object, and look for and remove those in "readFromDisk" instead.

Presumably you're also having some problem with the way your proxy works which is causing the original objects to be unavailable when you unarchive, but you don't show enough code to see the cause of that.




John Shockey john ATSIGN johncshockey DOT 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

-- Michael Tyson | michael.tyson.id.au

m: (+61) 0407 754 124
e: email@hidden
aim: mikerusselltyson

_______________________________________________

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: Using proxy objects with NSMutableArray
      • From: John Shockey <email@hidden>
References: 
 >Using proxy objects with NSMutableArray (From: Michael Tyson <email@hidden>)
 >Re: Using proxy objects with NSMutableArray (From: John Shockey <email@hidden>)

  • Prev by Date: Re: What are the official limits of Cocoa when it comes to the length of path names?
  • Next by Date: Re: What are the official limits of Cocoa when it comes to the length of path names?
  • Previous by thread: Re: Using proxy objects with NSMutableArray
  • Next by thread: Re: Using proxy objects with NSMutableArray
  • Index(es):
    • Date
    • Thread