• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Problems with image cell in table view (was: Re: NSImage -isValid not always right?)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Problems with image cell in table view (was: Re: NSImage -isValid not always right?)


  • Subject: Problems with image cell in table view (was: Re: NSImage -isValid not always right?)
  • From: j o a r <email@hidden>
  • Date: Fri, 12 Apr 2002 19:56:59 +0200

Hello Ramesh,

You don't say where in your code the snippet is from. It doesn't seem to really fit anywhere unfortunately... :)
I would set the cell type for columns in awakeFromNib - before they are used, but after they have been loaded from the nib. You should not set an image for the cell at this point - that is something you do later on in the table data source methods. Something like this:

- (void) awakeFromNib
{
// Your other stuff

// Set the cell type
{
NSTableColumn *col = [myTableView tableColumnWithIdentifier:@"ImageColumn"];
NSImageCell *myImageCell = [[NSImageCell alloc] init];
[col setDataCell:[myImageCell autorelease]];
}
}

- (id)tableView:(NSTableView *)aTableView objectValueForTableColumn:(NSTableColumn *)aTableColumn row:(int)rowIndex
{
if ([[aTableColumn identifier] isEqualToString:@"ImageColumn"]) {
// Here you must make sure to return a proper object value for the
// cell, or else you will get errors
return [NSImage imageNamed:@"image.giff"];
} else {
NSLog(@"This should never happen");
return nil;
}
}

j o a r


On Friday, April 12, 2002, at 06:56 , Peesapaty Ramesh wrote:

Hi,
i am trying to display a image in tableView .
the code is as follows.


NSImageCell *myImageCell;
NSTableColumn *col = [folderList
tableColumnWithIdentifier:@"folder"];
NSImage *myImage = [[NSImage alloc]
initWithContentsOfFile:@"folder.gif"];

if ([myImage isValid]){
NSLog(@"Image is valid");
}
if ([myImage isKindOfClass:[NSImage class]]){
NSLog(@"YES");
}
myImageCell = [[NSImageCell alloc] init];
[myImageCell setImage:myImage];
[col setDataCell:myImageCell];

when it is setting value in the tablecolumn it is giving following
error.
"NSImageCell's object value must be an NSImage."
am i missing anything.

thanks in advance.
Ramesh
_______________________________________________
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.

References: 
 >Re: NSImage -isValid not always right? (From: "Peesapaty Ramesh" <email@hidden>)

  • Prev by Date: Re: ever felt like a complete BOZO??
  • Next by Date: NSWindow questions
  • Previous by thread: Re: NSImage -isValid not always right?
  • Next by thread: Re: Easy, stupid question about window delegates
  • Index(es):
    • Date
    • Thread