NSTableView bound to NSArrayController
Within Interface Builder I've got an NSTableView with two columns bound to a vanilla NSArrayController. The NSArrayController has its Content Array bound to an NSMutableArray in my application delegate. I've used further bindings to setup the addition and removal of rows via bin开发者_StackOverflow社区dings (magic!).
The issue I'm running into now is that I'd like to grab the currently selected NSTableView row and use its index to look-up the object stored in my NSArrayControllers associated array. The problem I'm running into is trying to access the NSTableView.
Within my application delegate, using the following code will cause my application to crash:
NSLog(@"%@", [timersTableView selectedRow]);
Similarly, this also causes my application to crash:
NSLog(@"%@", [timersController selectionIndex]);
Given the simplicity of the code above, I must be doing something fundamentally wrong?
Both -selectedRow and -selectionIndex return an NSInteger, which is just an integer of native width, while the %@ format string specifier is for printing objects. Replace it with %ld if you want to print an NSInteger.
精彩评论