开发者

Binding a selector to the target of a NSButtonCell

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];开发者_如何学Python

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.


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

All sorted.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜