在取消选中绑定的NSTableview列中的复选框时出现问题 [英] Problems when deselecting checkboxes inside bound NSTableview's columns
问题描述
我使用的是这个专案,由 aneesh171 ,它显示了在NSTableView内创建复选框以及如何绑定它们。我是OSX开发的新手,试图了解它是如何工作的。
I am using this project, created by aneesh171 that shows the creation of checkboxes inside NSTableView and how to bind them. I am new to OSX development and trying to understand how it works.
该项目基本上是一个NSTableView的列中绑定到数组控制器的复选框。
The project is basically checkboxes inside a NSTableView's column that is bound to an array controller.
由于某些原因,当我取消选中其中一个复选框时,控制台窗口中会显示以下消息:
For some reason, when I deselect one of those checkboxes, the following messages appear on the console window:
2014-04-03 04:22:55.579 MyApp[5735:303] Error setting value for key path objectValue.selected of object <NSAutounbinder: 0x600000258120 - a nonretaining proxy for <NSTableCellView: 0x60000019f890>> (from bound object <NSButton: 0x60000015efb0>): [<__NSDictionaryI 0x61000006f540> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key selected.
2014-04-03 04:22:55.581 MyApp[5735:303] (
0 CoreFoundation 0x00007fff87b3a25c __exceptionPreprocess + 172
1 libobjc.A.dylib 0x00007fff8a3f6e75 objc_exception_throw + 43
2 CoreFoundation 0x00007fff87b3a038 +[NSException raise:format:arguments:] + 104
3 AppKit 0x00007fff927936c5 -[NSBinder _setValue:forKeyPath:ofObject:mode:validateImmediately:raisesForNotApplicableKeys:error:] + 837
4 AppKit 0x00007fff92793327 -[NSBinder setValue:forBinding:error:] + 245
5 AppKit 0x00007fff92c8b4ee -[NSValueBinder _applyObjectValue:forBinding:canRecoverFromErrors:handleErrors:typeOfAlert:discardEditingCallback:otherCallback:callbackContextInfo:didRunAlert:] + 194
6 AppKit 0x00007fff92c8b871 -[NSValueBinder applyDisplayedValueHandleErrors:typeOfAlert:canRecoverFromErrors:discardEditingCallback:otherCallback:callbackContextInfo:didRunAlert:error:] + 621
7 AppKit 0x00007fff927c5107 -[NSValueBinder performAction:] + 288
8 AppKit 0x00007fff927c4fc5 -[_NSBindingAdaptor _objectDidTriggerAction:bindingAdaptor:] + 133
9 AppKit 0x00007fff927531a0 -[NSControl sendAction:to:] + 56
10 AppKit 0x00007fff9279fced -[NSCell _sendActionFrom:] + 128
11 AppKit 0x00007fff927b96c5 -[NSCell trackMouse:inRect:ofView:untilMouseUp:] + 2316
12 AppKit 0x00007fff927b8a97 -[NSButtonCell trackMouse:inRect:ofView:untilMouseUp:] + 487
13 AppKit 0x00007fff927b81ad -[NSControl mouseDown:] + 706
14 AppKit 0x00007fff92739b48 -[NSWindow sendEvent:] + 11296
15 AppKit 0x00007fff926d86e4 -[NSApplication sendEvent:] + 2021
16 AppKit 0x00007fff92528b89 -[NSApplication run] + 646
17 AppKit 0x00007fff92513913 NSApplicationMain + 940
18 MyApp 0x0000000100049132 main + 34
19 libdyld.dylib 0x00007fff85ffe5fd start + 1
你能告诉我有什么不对吗?
Can you guys tell me what is wrong?
推荐答案
我更新了项目的git版本。
I updated the git version of the project.
每当你通过值绑定绑定一个控件,然后调用它的getter方法加载价值。而当您尝试修改这些值时,它将尝试调用属性的setter方法。在项目中,字典被硬编码,因此没有设置方法,这就是为什么你得到错误设置值的键路径objectValue.selected。
Whenever you bind a control through value binding, then it calls its getter method to load the values. whereas when you tries to modify these values, it will try to call the setter method of the property. In the project the dictionaries were hardcoded therefore there were no setter method and that is the reason why you got the "Error setting value for key path objectValue.selected".
检查
如果您遇到任何问题,请与我们联系。
Let me know if you face any problems.
这篇关于在取消选中绑定的NSTableview列中的复选框时出现问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!