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: Andre Masse <email@hidden>
- Date: Tue, 02 Dec 2008 01:16:52 -0500
Thanks for the clarification Michael. One thing I'm discovering as I'm
learning Cocoa is that it's easy to forget basic things. You set
connections, bindings, data sources or delegates graphically between
your objects in IB and when you run your application, all seems to
work like "magic". You're left with the impression that if you set
things, they will be "unset" somehow, somewhere using the same
"magic". As you go further, you discover that the magic is no magic at
all and the "magician" can't do it all by himself. You have to do some
work to keep the illusion alive.
Cheers to all the people on this list! You're all helping me becoming
a better Cocoa programmer...
Thanks,
Andre Masse
On Dec 1, 2008, at 23:59, Michael Ash wrote:
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