I have an NSTableView with a checkbox column and an NSArrayController.
The NSTableView is bound to the NSArrayController to show its content.
The checkbox column is bound to imgArrayController.arrangedObjects.check1. When the program starts the array is empty. I add values using the arrayController in a loop this way:
[imgArrayController addObject:[NSDictionary dictionaryWithObjectsAndKeys:
[NSImage imageNamed: [NSString stringWithFormat:@"%@" ,fileName]], @"image",
[NSString stringWithFormat:@"%@" ,fileName], @"filename",
@"YES", @"check1",
nil]];
The correct number of rows are added, however I am getting an error when it tries to set checkbox to YES. This is the error I get:
2013-02-03 19:11:46.357 Stockuploader[561:303] Error setting value for key path check1 of object {
} (from bound object <NSTableColumn: 0x100152280> identifier: check1): [<__NSDictionaryI 0x10010c190> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key check1.
Could somebody please help me to understand what I am doing wrong? The rows appear inside the table but they are all empty.
Try using
NSMutableDictionaryinstead ofNSDictionary. Also try using[NSNumber numberWithBool: YES]instead of@"YES"(which is a string, not a boolean).EDIT:
In a cell-based
NSTableViewyou would need to bind the column (not the cell itself) to the arrayController with a Controller Key of arrangedObjects and a Model Key Path ofcheck1.In a view-based
NSTableViewyou would need to bind the checkbox control to the Table Cell View with a Model Key Path ofobjectValue.check1.