• 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
Re: Custom tableView cell by subclassing NSCell
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Custom tableView cell by subclassing NSCell


  • Subject: Re: Custom tableView cell by subclassing NSCell
  • From: Malayil George <email@hidden>
  • Date: Tue, 5 May 2009 20:48:11 -0400

just found
http://developer.apple.com/samplecode/ImageBackground/listing3.html after
posting this...going through it to see if I can figure  it out :-)

On Tue, May 5, 2009 at 8:41 PM, Malayil George <email@hidden> wrote:

> Hi,   I'm trying to expand on "Styling an NSTableView" at katidev.com in a
> test app of mine. The modification that I have made is that in my subclass
> of NSCell, I have included a new NSImage data element
>
> @interface CustomCell : NSCell {
>
> NSImage *image;
>
> }
>
> @end
>
>    In my appController, I set the tableView to use this cell
>
> CustomCell *cell = [[CustomCell alloc] init];
>
> [[tableView tableColumnWithIdentifier:@"Cities"] setDataCell:cell];
>
> [cell release];
>
>
> and I set the image for the cell in my implementation of
>
>
>  -(void) tableView:(NSTableView*) aTableView
>
>   willDisplayCell:(id) aCell
>
>    forTableColumn:(NSTableColumn *) aTableColumn
>
>   row:(int) rowIndex
>
>
> When I run the program, it displays the image fine. However, when I click
> on the table row's it crashes. I see that it is deallocing my cell (via an
> NSLog()) in the CustomCell's dealloc method. So, I guess it is crashing as
> the cell is being dealloced, and then in willDisplayCell, it is trying to
> set the image.
>
>
> I tried setting aCell in the willDisplayCell method to a newly allocated
> instance of CustomCell and also tried doing the setDataCell method with that
> new instance. It still crashes...should I be initializing the cell someplace
> else?
>
> Reading the documentation it seems that a single cell is used for all rows
> of the table Column. So, I'm guessing when the application launches it is
> using my initialized customCell for all rows and displaying it without
> deallocing it. However, when I click a row, it deallocs and tries to do the
> same again.
>
> Any pointers on if and when I should be giving the tableView a newly
> allocated instance of the cell? Thanks
>
>
>
> George
>
>
>
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Custom tableView cell by subclassing NSCell
      • From: Malayil George <email@hidden>
References: 
 >Custom tableView cell by subclassing NSCell (From: Malayil George <email@hidden>)

  • Prev by Date: Custom tableView cell by subclassing NSCell
  • Next by Date: Re: Custom tableView cell by subclassing NSCell
  • Previous by thread: Custom tableView cell by subclassing NSCell
  • Next by thread: Re: Custom tableView cell by subclassing NSCell
  • Index(es):
    • Date
    • Thread