• 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: NSTableView, NSArrayController, and ImageAndTextCell
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSTableView, NSArrayController, and ImageAndTextCell


  • Subject: Re: NSTableView, NSArrayController, and ImageAndTextCell
  • From: Alastair Houghton <email@hidden>
  • Date: Sat, 8 Nov 2003 09:37:20 +0000

On 8 Nov 2003, at 07:47, mmalcolm crawford wrote:

Notice from the outline view example that the image is set independently of the text:

- (void)outlineView:(NSOutlineView *)olv willDisplayCell:(NSCell *)cell forTableColumn:(NSTableColumn *)tableColumn item:(id)item {
if ([[tableColumn identifier] isEqualToString: COLUMNID_NAME]) {
// Make sure the image and text cell has an image. If not, give it something random.
if (item && ![NODE_DATA(item) iconRep]) [NODE_DATA(item) setIconRep: [self _randomIconImage]];
// Set the image here since the value returned from outlineView:objectValueForTableColumn:... didn't specify the image part...
[(ImageAndTextCell*)cell setImage: [NODE_DATA(item) iconRep]];
// ...

It's cleaner IMHO to write the cell's -setObjectValue to accept an object that contains both text and an image (you could use an NSArray with two elements, or you could use a custom container object of some type). That way you don't have to set the image or the text in your willDisplayCell: method... you just do it the usual way, by returning your object from objectValueForTableColumn: method.

I see no reason why that wouldn't work with NSArrayController.

Kind regards,

Alastair.
_______________________________________________
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.

  • Follow-Ups:
    • Re: NSTableView, NSArrayController, and ImageAndTextCell
      • From: Vincent Coetzee <email@hidden>
    • Re: NSTableView, NSArrayController, and ImageAndTextCell
      • From: Vincent Coetzee <email@hidden>
    • Re: NSTableView, NSArrayController, and ImageAndTextCell
      • From: mmalcolm crawford <email@hidden>
References: 
 >NSTableView, NSArrayController, and ImageAndTextCell (From: Kurt Marek <email@hidden>)
 >Re: NSTableView, NSArrayController, and ImageAndTextCell (From: mmalcolm crawford <email@hidden>)

  • Prev by Date: Re: Controller Layer and Automatic Key-Value Observing
  • Next by Date: Re: NSTableView, NSArrayController, and ImageAndTextCell
  • Previous by thread: Re: NSTableView, NSArrayController, and ImageAndTextCell
  • Next by thread: Re: NSTableView, NSArrayController, and ImageAndTextCell
  • Index(es):
    • Date
    • Thread