Re: Crash when closing window from the menu
Re: Crash when closing window from the menu
- Subject: Re: Crash when closing window from the menu
- From: "Michael Ash" <email@hidden>
- Date: Mon, 1 Dec 2008 23:59:25 -0500
On Mon, Dec 1, 2008 at 2:54 PM, Jerry Krinock <email@hidden> wrote:
>
> On 2008 Dec, 01, at 6:12, Jean-Daniel Dupas wrote:
>
>> - (void)dealloc {
>> [_tableView setDataSource:nil];
>> [_otherIVar setDelegate:nil];
>
> According to [1], you need one more line of code here:
> [tableView reloadData];
That document describes the scenario where you destroy your data
objects, not where you destroy the data source yourself. The call to
setDataSource: is sufficient, as it can no longer query you after that
point.
In general, you always need to clear any weak references to your
objects when they are deallocated. This is most well known for the
weak references you get from NSNotificationCenter, but it applies to
other weak references such as delegate and data source references as
well. For those you can often get away with not clearing them if they
end up getting deallocated at the same time, but as people are
discovering here, in some situations you can't count on that.
Mike
_______________________________________________
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