sha*_*rgy 0 cocoa objective-c nsdictionary nstableview
我有NSTableView一个复选框列和一个NSArrayController.
将NSTableView被绑定到NSArrayController以显示其内容.复选框列绑定到imgArrayController.arrangedObjects.check1.程序启动时,数组为空.我以这种方式在循环中使用arrayController添加值:
[imgArrayController addObject:[NSDictionary dictionaryWithObjectsAndKeys:
[NSImage imageNamed: [NSString stringWithFormat:@"%@" ,fileName]], @"image",
[NSString stringWithFormat:@"%@" ,fileName], @"filename",
@"YES", @"check1",
nil]];
Run Code Online (Sandbox Code Playgroud)
添加了正确的行数,但是当我尝试将复选框设置为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.
Run Code Online (Sandbox Code Playgroud)
有人可以帮我理解我做错了什么吗?行显示在表格内,但它们都是空的.
尝试使用NSMutableDictionary而不是NSDictionary.也尝试使用[NSNumber numberWithBool: YES]而不是@"YES"(这是一个字符串,而不是一个布尔值).
编辑:
在基于单元格的情况下,NSTableView您需要使用arrangeObjects的Controller Key和Model Key Path of 将列(不是单元格本身)绑定到arrayController check1.
在基于视图的情况下,NSTableView您需要使用模型键路径将复选框控件绑定到表格单元格视图objectValue.check1.
| 归档时间: |
|
| 查看次数: |
840 次 |
| 最近记录: |