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: publiclook <email@hidden>
- Date: Tue, 8 Apr 2003 21:02:15 -0400
You are not retaining the objects created in -init and therefore they
are being deallocated before you attempt to use them. You need to
learn the memory management conventions imposed by the frameworks you
are using. Read the book on Objective-C that is already on your hard
disk or under the "Getting Started" section of
http://developer.apple.com/techpubs/macosx/Cocoa/CocoaTopics.html.
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.
_______________________________________________
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.