views:

158

answers:

1

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 bindings (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?

A: 

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.

Boaz Stuller
You're, of course, absolutely correct. What a foolish mistake! On the plus side, I read up on how the %@ format string specifier operates.
ndg