On 20/03/2009, at 4:43 AM, Jo Phils wrote:

I am still a Cocoa beginner and looking for some help. Based on Using a Table Data Source in the Table View Programming Guide I have initiated my Table View with 2 columns...one for filenames and one for checkboxes (NSButtonCell). Everything is fine except this method:

- (void)tableView:(NSTableView *)aTableView
   setObjectValue:anObject
   forTableColumn:(NSTableColumn *)aTableColumn
   row:(int)rowIndex

I can't seem to get the right syntax to tell my Table View to toggle the state. I am able to initiate my Table View with the checkboxes in the ON state (other method) but this method is where I'm stuck. My source is a NSArray *filenames and my table column is "column2." If someone could help show me how to code this I would appreciate it very much not just to get me passed this point but also so I can learn what I'm doing wrong. :-)


You don't actually state clearly what the problem is, but there is a minor error above:

   setObjectValue:anObject

should be:

   setObjectValue:(id) anObject

is that it?

I believe that types left out default to <id> so it may not be. If your question is "how do I toggle the state of something in my data model when the checkbox is changed?" then this may help:


- (void) tableView:(NSTableView*) tv setObjectValue:(id) objectVal forTableColumn:(NSTableColumn*) column row:(int) rowIndex
{
        id someObject;

        someObject = [[self dataModel] objectAtIndex:rowIndex];

        [someObject setValue:objectVal forKey:[column identifier]];
}

where [column identifier] returns the string which is the property key for the boolean property of interest that the checkbox is representing. You set this in IB, e.g. @"myBooleanProperty"


--Graham


_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to