Re: NSImage cell tanking (and slow NSTableView)
Re: NSImage cell tanking (and slow NSTableView)
- Subject: Re: NSImage cell tanking (and slow NSTableView)
- From: John Timmer <email@hidden>
- Date: Fri, 16 May 2003 19:08:09 -0400
I've (sortof) answered my own question. If I create the NSImageCell and
immediately hand it off to the TableView, it does not crash. If I try to
store the Image Cell in an array, and retrieve it later for use in the
TableView, it crashes. It seems that allowing the code that crashes would
help speed up a Table View, since there's much less allocation and setting
of properties when you simply retrieve a cell that already exists.
Plus, there's nothing in the documentation that indicates a cell must be
used immediately for it to actually work.
John
>
Greetings:
>
>
I'm using the following code to create an NSImageCell:
>
>
- (NSImageCell *) getCellWithImage: (NSImage *)theImage {
>
NSImageCell *theCell = [[[NSImageCell alloc] initImageCell: theImage]
>
autorelease];
>
[theCell setImageScaling: NSScaleProportionally];
>
if ( [theCell hasValidObjectValue] )return theCell;
>
else return nil;
>
}
>
>
And then storing the Image Cell in an NSMutableArray that is used to
>
populate an NSTableView (I've overridden the - (id)dataCellForRow:(int)row
>
method in a custom NSTableColumn class in order to mix cell types), so
>
everything should be retained. Everything works fine until the table gets
>
redrawn, at which point it tanks with the following:
>
>
2003-05-16 13:10:41.010 CocoaTest[18268] NSImageCell's object value must be
>
an NSImage.
>
2003-05-16 13:10:41.025 CocoaTest[18268] *** Uncaught exception:
>
<NSInvalidArgumentException> NSImageCell's object value must be an NSImage.
>
>
The image is originally loaded from the bundle with:
>
NSImage *theImage = [NSImage imageNamed: @"mouse"];
>
>
At first I thought the image might not be retained by the cell, but adding a
>
retain to the image loading made no difference.
>
>
I've tried to include all the pertinent code, but may have missed something.
>
Any help would be appreciated,
>
>
John
_______________________________________________
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.