Re: Using proxy objects with NSMutableArray
Re: Using proxy objects with NSMutableArray
- Subject: Re: Using proxy objects with NSMutableArray
- From: John Shockey <email@hidden>
- Date: Fri, 13 Jul 2007 12:15:02 -0400
On Jul 13, 2007, at 10:28 AM, Michael Tyson wrote:
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.
Looking again at your code, I think I see an additional problem. And
again, it's the sort of thing that could cause all sorts of odd
behavior, though I'm not specifically sure of what you're seeing.
The documentation for "unarchiver:didDecodeObject:" doesn't say
anything about retaining and releasing objects, so I would assume
that you're expected to follow the normal procedure. That would mean
you should not release the object you receive, even when you are
returning something else. I would also assume that you should be
returning an autoreleased object as the replacement, and not
retaining it. It is presumably the responsibility of
NSKeyedUnarchiver to handle all that.
(To reinforce that, if you look at the methods
"replacementObjectForCoder:" and "awakeAfterUsingCoder:" defined on
NSObject, the documentation for the latter DOES tell you to release
the object if you're returning something else. I'm not suggesting
that you need to use these methods instead -- just observing that
Apple's documentation is generally pretty explicit where you need to
differ from standard memory management behavior.)
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