Re: Cleaning up weak references ( was Re: Odd Crash when adding table columns manually )
Re: Cleaning up weak references ( was Re: Odd Crash when adding table columns manually )
- Subject: Re: Cleaning up weak references ( was Re: Odd Crash when adding table columns manually )
- From: Quincey Morris <email@hidden>
- Date: Thu, 20 Jan 2011 11:38:06 -0800
On Jan 20, 2011, at 07:22, Eric Gorr wrote:
> I was wondering why this was such a surprise to me, so I went hunting through sample code, books, etc.
>
> I cannot seem to find any sample code, either in books (even Cocoa Programming for Mac OS X (3rd Edition)) or in Apple's own sample code where they follow these rules. I think that is why it has surprised me. I sure there must be some out there that do follow these rules, but the examples seem to be rare at the moment.
Well, any answer to that is likely to be a bit speculative, but I think at least the following factors enter into it:
1. Apple people having been making this point for some time, but it hasn't widely been taken up by third party developers. This is one of those policies that's been more "honored in the breach".
2. In many cases, failing to adhere to the policy *doesn't* lead to a crash, for unrelated reasons (the relevant objects are already owned by something else, for example).
3. As you've noted, it can be hard to keep a firm grip on which object needs to do what to whom at which time, especially when there are multiple delegate patterns in play. Sometimes it's tempting *not* to think it through, but just to do something or other, and wait to see if it fails. That's possibly what happened to the sample code.
_______________________________________________
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