Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/macos/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Macos 核心数据阵列控制器绑定:ValueForUnfinedKey_Macos_Cocoa_Core Data_Nsarraycontroller - Fatal编程技术网

Macos 核心数据阵列控制器绑定:ValueForUnfinedKey

Macos 核心数据阵列控制器绑定:ValueForUnfinedKey,macos,cocoa,core-data,nsarraycontroller,Macos,Cocoa,Core Data,Nsarraycontroller,全部 我有一个NSTableView和一个NSTextFields,它们显示在NSWindow中。在IB。 实体是这样设计的 Entity: Data Attributes: Title String URL String UserName String Password String 我已成功地将NSArrayController绑定到managedObjectContext,将NSTableView绑定到arrayContro

全部

我有一个NSTableView和一个NSTextFields,它们显示在NSWindow中。在IB。 实体是这样设计的

Entity: Data
Attributes:
    Title      String
    URL        String
    UserName   String
    Password   String
我已成功地将NSArrayController绑定到managedObjectContext,将NSTableView绑定到arrayController的Title属性,并且NSTableView可以正确显示所有标题

我想执行以下任务:

When user click one of the row in the NSTableView, the rest of the three NSTextFields can show the records of that row, respectively URL< username and password.
因此,我对URL部分执行以下操作

将NSTextField绑定到NSArrayController的selection.URL

当我运行程序时,它会给出错误,但是,如果我在binding属性中取消选中不适用键的提升,程序可以成功启动,并且值可以正确显示在文本字段中。有人能解释为什么吗

错误显示:

 [<NSTableView 0x102240d60> valueForUndefinedKey:]: this class is not key value coding-compliant for the key URL.
以下是错误日志的一部分:

2012-01-17 11:52:57.533 Quills[98683:407] An uncaught exception was raised 2012-01-17 11:52:57.534 Quills[98683:407] [<NSTableView 0x102240d60> valueForUndefinedKey:]: this class is not key value coding-compliant for the key URL. 2012-01-17 11:52:57.540 Quills[98683:407] (   0   CoreFoundation                      0x00007fff8abd2286 __exceptionPreprocess + 198  1   libobjc.A.dylib    0x00007fff8d84cd5e objc_exception_throw + 43     2   CoreFoundation       0x00007fff8ac5c4c9 -[NSException raise] + 9    3   Foundation            0x00007fff8d1e8783 -[NSObject(NSKeyValueCoding) valueForUndefinedKey:]
+ 240   4   Foundation                          0x00007fff8d11f462 _NSGetUsingKeyValueGetter + 108  5   Foundation                          0x00007fff8d11f3e9 -[NSObject(NSKeyValueCoding) valueForKey:] + 392     6 Foundation                          0x00007fff8d13ee76
-[NSObject(NSKeyValueCoding) valueForKeyPath:] + 348    7   AppKit                              0x00007fff85ab33f1 -[NSArrayController
_multipleValueForKeyPath:atIndex:] + 84     8   AppKit                              0x00007fff85ab24e5 -[NSArrayController _singleValueForKeyPath:] + 151   9   AppKit                              0x00007fff8581909a
-[_NSControllerObjectProxy valueForKeyPath:] + 77   10  Foundation                          0x00007fff8d13ee39 -[NSObject(NSKeyValueCoding) valueForKeyPath:] + 287     11  AppKit                              0x00007fff85818f46
-[NSBinder _valueForKeyPath:ofObject:mode:raisesForNotApplicableKeys:] + 654    12  AppKit                              0x00007fff85818c30 -[NSBinder valueForBinding:resolveMarkersToPlaceholders:] + 171  13  AppKit                              0x00007fff85a1cc92 -[NSValueBinder
_referenceBindingValue] + 31    14  AppKit                              0x00007fff85a1caa3 -[NSValueBinder
_adjustObject:mode:observedController:observedKeyPath:context:editableState:adjustState:]
+ 647   15  AppKit                              0x00007fff85a1c788 -[NSValueBinder _observeValueForKeyPath:ofObject:context:] + 303     16  AppKit                              0x00007fff85a345af
-[NSTextValueBinder _observeValueForKeyPath:ofObject:context:] + 43     17  AppKit                              0x00007fff8580abdb
-[NSObject(NSKeyValueBindingCreation) bind:toObject:withKeyPath:options:] + 591

我遇到了完全相同的问题,除了一个NSOutlineView和一个NSTreeController

我的问题是,我已将我的NSTreeController的内容出口连接到我的NSOutlineView。我一删除它,对选择的引用就开始工作了


我怀疑您可能做了类似的操作,因为您的错误是NSTableView缺少密钥,而不是NSManagedObject。

请确保已将URL密钥绑定到ArrayController Hi,Shanti,为什么?My array controller绑定managedObjectContext,NtableView绑定arrayController中的arrangedObject.title,URL文本字段应显示与NtableView中的选定标题相对应的URL。因此,当我在NSTableView中选择一个标题时,选择将引用此数据,因此,selection.URL将指向URL属性,这有意义吗?如果不是,我应该用什么属性将此URL绑定到阵列控制器内容?@Sheldon你说得很有道理。我遇到了完全相同的问题。首先,不要调用您的核心数据实体数据或字符串或任何东西。如果确实要使用数据,请在其前面加上Sheldon_数据之类的前缀。核心数据在很大程度上依赖于字符串解析,很容易混淆。其次,属性应该是小写的,比如标题、url、用户名等。