Re: Odd Crash when adding table columns manually
Re: Odd Crash when adding table columns manually
- Subject: Re: Odd Crash when adding table columns manually
- From: Corbin Dunn <email@hidden>
- Date: Wed, 19 Jan 2011 16:28:09 -0800
Hi eric,
As I mentioned earlier, it is good practice to set your delegate/ds to nil, since people inadvertently don't realize when they tell the table to redraw, and are
surprised when they get the delegate messages after they are deallocd. I looked at your app, and I can point out the problem (I didn't run it, sorry):
- (void) dealloc
{
NSArray* tableColumns = [table tableColumns];
MyColumn* column;
for ( column in tableColumns )
{
[table removeTableColumn:column];
}
[table release];
[super dealloc];
}
You are removing table columns, which the table marks that area as dirty, and redraws. Which calls your delegate/datasource (which is dealloced, clearly, since it is in dealloc)
That's what you are doing wrong in your code. It's okay to do it there as long as you realize what is happening...but I would recommend not doing it there , since it has side effects, and causes this problem you see.
Running instruments would point out the msg send was to your class.
corbin
On Jan 19, 2011, at 3:35 PM, Eric Gorr wrote:
> Hi Corbin,
>
> I'm not using a custom cell. Just the standard text field one. I would assume that it has implemented -copyWithZone correctly :-)
>
> Feel free to check out the sample project, but I believe the correct answer is to just set the datasource and delegate to nil as things are being deallocated. The fact that I wasn't doing something I should be doing (?) is what was causing it to crash.
>
> Since it may not have been clear, after pushing the button, which is when the crash occurs, causes the modal event loop to end and everything to be deallocated.
_______________________________________________
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