Re: NSTableView and crashes, what am I doing wrong?
Re: NSTableView and crashes, what am I doing wrong?
- Subject: Re: NSTableView and crashes, what am I doing wrong?
- From: Greg Casey <email@hidden>
- Date: Wed, 9 Apr 2003 00:02:14 -0400
[NSMutableArray array] returns an autoreleased array. You need to
retain it to keep it around, otherwise it will get wiped out when the
autorelease pool is emptied. Same thing applies to [NSMutableDictionary
dictionary].
-gtc
On Tuesday, April 8, 2003, at 03:50 PM, Henrik Eliasson wrote:
Dear all,
I'm getting desperate over very strange behavior when trying to
implement an ordinary table uing NSTableView. In Interface Builder, I
have made a window containing an ordinary table view. I have connected
this table view to a controller object as dataSource in which I have
implemented the methods numberOfRowsInTableView: and tableView:
setObjectValue: forTableColumn:. I am using two objects to store the
data to be displayed in the table, a NSMutableArray and a
NSMutableDictionary. I allocate these in the init: method of the
controller object, like so:
- (id)init {
self = [super init];
glassDict = [NSMutableDictionary dictionary];
glassArray = [NSMutableArray array];
return self;
}
Nothing strange with that, I hope. The strange thing happens when the
numberOfRowsInTableView: method gets called, which happens right after
the window in which the table view is located is made visible using the
makeKeyAndOrderFront: message. When the numberOfRowsInTableView: method
gets called, the program crashes with a signal 11 (SIGSEGV). The only
thing this method does is to return the number of elements in the
glassArray according to:
- (int)numberOfRowsInTableView:(NSTableView *)tableView {
return [[self glassArray] count];
}
Could anyone explain what is going on here?
/Henrik
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.
-gtc
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.