Re: EXC_BAD_ACCESS in NSTableView adding object when visible
Re: EXC_BAD_ACCESS in NSTableView adding object when visible
- Subject: Re: EXC_BAD_ACCESS in NSTableView adding object when visible
- From: Sandro Noel <email@hidden>
- Date: Sat, 26 May 2007 22:37:26 -0400
If you create the objects with one of it's initWith.... class methods
the object needs to retained because it is usualy created with an
autorelease.
make sure you retain your objects before puting them into the model
for your TableView ...
and make sure you do not create your own classes with autorelease
for example: [[[classname alloc] init] autorelease]
it will die as short after you fall out of scope.
I had that problem not so long ago ...
i'm new too :) and loving it!
Sandro Noel
email@hidden
On 26-May-07, at 10:29 PM, Michael Watson wrote:
In addition to the solid advice James gives here, it would probably
also be useful to post code that triggers the crash, if possible.
--
m-s
On 26 May, 2007, at 18:15, James Bucanek wrote:
Timothy Collett <mailto:email@hidden> wrote (Saturday,
May 26, 2007 11:28 AM -0400):
Greetings. I am still pretty new at Cocoa, and I am experiencing
a bad
access error in an NSTableView when adding an object to its data
source while the table is visible, or on the first time
attempting to
show the NSTableView after adding the object. According to the
stack
view visible in the debugger window, the bad access occurs when
trying
to set the value of the cell. It makes me think I've not
allocated or
retained something correctly, but I'm not sure what.
This is probably an over-released object. You should be able to
verify this by turning on the NSZombie options (see <http://
developer.apple.com/technotes/tn2004/tn2124.html>).
One thing to look out for with NSCell is that NSCell objects get
copied constantly. They are "rubber stamps" used over and over
again to draw the contents of rows, and whenever they are needed
the table/outline classes make a copy of them. If you've
subclassed NSCell make sure you are implementing all of the NSCopy
protocols correctly. If you don't, you get two NSCells both
referencing a single object with a single retain. Then one NSCell
gets released and the second one blows up.
As I don't know of a way to get XCode to give me the stack trace in
textual form, I've taken a screenshot and posted it at
<http://homepage.mac.com/danaris/stacktrace.png>.
If you open up the console window for the debugger, you can chat
directly with gdb. You can issue gdb commands to get back traces,
dump variables, etc.
--
James Bucanek
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
40bungie.org
This email sent to email@hidden
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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