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: Esteban Uribe <email@hidden>
- Date: Tue, 08 Apr 2003 17:39:40 -0700
Hi Henrik,
On Tuesday, April 08, 2003, at 12:50PM, Henrik Eliasson <email@hidden> wrote:
>
- (id)init {
>
>
self = [super init];
>
>
glassDict = [NSMutableDictionary dictionary];
>
glassArray = [NSMutableArray array];
>
>
return self;
>
}
>
>
Nothing strange with that, I hope.
Well the problem is that you declare glassDict, and glassArray as autoreleased objects.
That means that they are only valid until the end of the method call.
So when numberOfRowsInTableView, glassDict and glassArray no longer point to valid
objects.
I suggest changing those two lines to the following.
glassDict = [[NSMutableDictionary alloc] init];
glassArray = [[NSMutableArray alloc] init];
this will ensure that the object's stick around until you explicitly call release on them.
Convenience constructors like [NSMutableDictionary dictionary] and [NSMutableArray array]
create objects that are only valid within the scope of the method in which they were called, so
you must alloc and init an object to retain it in the application's scope.
-Esteban
_______________________________________________
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.