views:

28

answers:

1

I'm using the following code to add a target binding to a NSButtonCell control:

[dataCell bind:@"target" toObject:eventDatesArray withKeyPath:@"selection.self" 
               options:[NSDictionary dictionaryWithObjectsAndKeys:@"sellTicket:",              
                                     NSSelectorNameBindingOption, nil]];

eventDatesArray is connected by Interface Builder to a NSArrayController. I have established this is done correctly by using the following working code:

[dataCell bind:@"title" toObject:eventDatesArray withKeyPath:@"selection.dateTime"
                                                     options:nil];

The "selection.self" maps to a specialised NSManagedObject which has a method sellTicket:(NSNumber *)maxTickets. Incidentally, I'm also setting the arguments binding:

[dataCell bind:@"argument" toObject:eventsArray withKeyPath:@"selection.venueCapacity"
                                                     options:nil];

eventsArray is another NSArrayController.

Where have I gone wrong with the target binding? It simply doesn't trigger the selector.

A: 

Answering my own question, it appears you need to bind the target and the argument to the NSTableColumn instead of the NSButtonCell.

All sorted.

John Mitchell