Re: an oldie but a goodie: observing properties of collected objects
Re: an oldie but a goodie: observing properties of collected objects
- Subject: Re: an oldie but a goodie: observing properties of collected objects
- From: Ken Thomases <email@hidden>
- Date: Thu, 17 Jun 2010 20:55:23 -0500
On Jun 17, 2010, at 8:07 PM, Jerry Krinock wrote:
> I was going to ask what happens if this object which owns 5000 widget objects gets deallocated. Their observers have not been removed and I would expect nastygrams like this [1]. But then I noticed that your observer is 'self'.
>
> Ken, is that part of your scheme, that the observer of the collection must also be the owner of the collection?
No.
> If so, since the objects will be deallocated slightly before the owner is, there is a small window of time where it's observing a deallocated object. Do you worry about that?
I didn't illustrate it, but you would unregister as an observer from all of the widgets before releasing the widgets array.
And, in general, you should make sure that observers unregister before the observed objects are deallocated. That's not unique to the technique I described.
Regards,
Ken
_______________________________________________
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