• 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 & different columns
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSTableView & different columns


  • Subject: Re: NSTableView & different columns
  • From: Dave Hersey <email@hidden>
  • Date: Sat, 02 Jul 2005 18:12:23 -0400

Actually, that was a bad example. You don't need the "set" methods unless
the data in the table is editable. Although, you may need them elsewhere to
access your data objects.

- Dave

On 7/2/05 6:05 PM, "Dave Hersey" <email@hidden> wrote:

> ...I forgot to mention that you don't need the "set" methods unless the data
> can change, like in the case of a checkbox value.
>
> - d
>
>> Or, you could use a key-value approach, which avoids the need for the if
>> statement. If you do it like this, then you just need methods in your data
>> objects that can respond to the column identifiers.
>>
>> So, if the identifiers are "number" and "button", you'd have number,
>> setNumber, button, and setButton methods in the data object and include the
>> code below in your table's data source. (Here, I was storing the table
>> objects using an array.)
>>
>> - Dave
>>
>>
>> - (id) tableView: (NSTableView *) tableView
>>     objectValueForTableColumn: (NSTableColumn *) tableColumn
>>     row: (int) rowIndex
>> {
>>   id            theObject = nil, theValue = nil;
>>   NSString    *identifier = [tableColumn identifier];
>>   NSArray        *dataStorage = [[tableView dataSource] dataStorage];
>>
>>   if (dataStorage)
>>   {
>>       theObject = [dataStorage objectAtIndex: rowIndex];
>>       theValue = [theObject valueForKey: identifier];
>>   }
>>
>>   return theValue;
>> }
>>
>>
>> - (void) tableView: (NSTableView *) tableView
>>       setObjectValue: (id) anObject
>>       forTableColumn: (NSTableColumn *) tableColumn
>>       row: (int) rowIndex
>> {
>>   id        theObject;
>>   NSString    *identifier = [tableColumn identifier];
>>   NSArray    *dataStorage = [[tableView dataSource] dataStorage];
>>
>>   if (dataStorage)
>>   {
>>       theObject = [dataStorage objectAtIndex: rowIndex];
>>       [theObject takeValue: anObject forKey: identifier];
>>   }
>> }

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >Re: NSTableView & different columns (From: Dave Hersey <email@hidden>)

  • Prev by Date: Re: NSTableView & different columns
  • Next by Date: Re: NSTableView & different columns
  • Previous by thread: Re: NSTableView & different columns
  • Next by thread: Re: NSTableView & different columns
  • Index(es):
    • Date
    • Thread