2013-02-03 167 views
0

我有一个NSTableView与复选框列和NSArrayController设置NSTableView内的复选框为“是”

NSTableView绑定到NSArrayController以显示其内容。 复选框列被绑定到imgArrayController.arrangedObjects.check1。当程序启动时,数组是空的。我在一个循环中添加使用arrayController值是这样的:

[imgArrayController addObject:[NSDictionary dictionaryWithObjectsAndKeys: 
     [NSImage imageNamed: [NSString stringWithFormat:@"%@" ,fileName]], @"image", 
     [NSString stringWithFormat:@"%@" ,fileName], @"filename", 
     @"YES", @"check1", 
     nil]]; 

添加正确的行数,当它试图复选框设置为YES但是我得到一个错误。这是我得到的错误:

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. 

有人能帮我理解我在做什么错吗?这些行出现在表格内,但它们都是空的。

回答

6

尝试使用NSMutableDictionary而不是NSDictionary。也请尝试使用[NSNumber numberWithBool: YES]而不是@"YES"(这是一个字符串,而不是布尔值)。

编辑:

在基于细胞的NSTableView你需要的(不是电池本身)的arrayController与arrangedObjects的控制器密钥和check1模型的关键路径进行绑定。

在基于视图NSTableView你需要绑定CheckBox控件表格单元格视图与objectValue.check1模型的关键路径。

+0

谢谢!尝试... – sharkyenergy

+0

谢谢,它不再给出错误,但复选框仍然没有设置。 – sharkyenergy

+0

这是基于NSTableView视图还是基于单元格? – ipmcc