objective-c – NSOutlineView:编辑绑定到NSTreeController的NSTextFieldCell时的异常

前端之家收集整理的这篇文章主要介绍了objective-c – NSOutlineView:编辑绑定到NSTreeController的NSTextFieldCell时的异常前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
当我在NSOutlineView中编辑NSTextFieldCell(在我点击后立即开始闪烁)时,我遇到了崩溃.

表列绑定到数据源.这些值在单元格中正确显示,绑定有效,只有在编辑单元格时才会出现问题.

[theEditingColumn bind:@"value" myTreeController withKeyPath:[NSString stringWithFormat:@"arrangedObjects.%@",Metadata.columnBindingKeyPath] options:bindingOptions];

这是我得到的例外.似乎NSTextFieldCell是从NSControllerTreeProxy设置/获取值而不是NSTreeController的内容.

-[_NSControllerTreeProxy _valueForKeyPath:ofObjectAtIndex:]: unrecognized selector sent to instance 0x1ae0370
2015-07-16 11:20:55.008 [2647:735628] (
    0   CoreFoundation                      0x90e2bc63 __raiseError + 195
    1   libobjc.A.dylib                     0x9488fa2a objc_exception_throw + 276
    2   CoreFoundation                      0x90e307c5 -[NSObject(NSObject) doesNotRecognizeSelector:] + 277
    3   CoreFoundation                      0x90d66758 ___forwarding___ + 1032
    4   CoreFoundation                      0x90d6632e _CF_forwarding_prep_0 + 14
    5   AppKit                              0x9b9dd459 -[NSBinder _valueForKeyPath:ofObject:mode:raisesForNotApplicableKeys:] + 294
    6   AppKit                              0x9bd3e661 -[NSBinder valueForBinding:atIndex:resolveMarkersToPlaceholders:] + 461
    7   AppKit                              0x9c0c91a5 -[NSValueBinder _referenceBindingValueAtIndex:] + 56
    8   AppKit                              0x9bc382c7 -[_NSValueBinderPlugin editingHasBegun:] + 265
    9   AppKit                              0x9bc381ae -[NSValueBinder _startChanging] + 183
    10  AppKit                              0x9bc3802c -[NSTextValueBinder _startChanging] + 51
    11  AppKit                              0x9bc37ff4 -[NSValueBinder editorDidBeginEditing:] + 33
    12  AppKit                              0x9bc37fc4 -[_NSBindingAdaptor _editor:didChangeEditingState:bindingAdaptor:] + 166
    13  AppKit                              0x9bc37eec -[_NSBindingAdaptor editorDidBeginEditing:] + 218
    14  AppKit                              0x9c01ed24 -[NSTableView textShouldBeginEditing:] + 201
    15  AppKit                              0x9bb64be0 -[NSTextView(NSSharing) shouldChangeTextInRanges:replacementStrings:] + 310
    16  AppKit                              0x9bb64a9f -[NSTextView(NSSharing) shouldChangeTextInRange:replacementString:] + 121
    17  AppKit                              0x9c06c2c5 -[NSTextView(NSKeyBindingCommands) insertCompletion:forPartialWordRange:movement:isFinal:] + 513
    18  MyApp                               0x004de3d9 -[CBAutocompleteTextField insertCompletion:forPartialWordRange:movement:isFinal:] + 457
    19  AppKit                              0x9c070541 -[NSTextViewCompletionController _reflectSelection:] + 215
    20  AppKit                              0x9c0738b1 -[NSTextViewCompletionController tableViewSelectionDidChange:] + 41
    21  Foundation                          0x93eaa053 __57-[NSNotificationCenter addObserver:selector:name:object:]_block_invoke + 50
    22  CoreFoundation                      0x90de0c34 __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ + 20
    23  CoreFoundation                      0x90cc0901 _CFXNotificationPost + 3713
    24  Foundation                          0x93e8b224 -[NSNotificationCenter postNotificationName:object:userInfo:] + 92
    25  Foundation                          0x93e9e772 -[NSNotificationCenter postNotificationName:object:] + 56
    26  AppKit                              0x9ba1ce87 -[NSTableView _sendSelectionChangedNotificationForRows:columns:] + 169
    27  AppKit                              0x9b9e94ff -[NSTableView _enableSelectionPostingAndPost] + 410
    28  AppKit                              0x9ba1c619 -[NSTableView _doSelectIndexes:byExtendingSelection:indexType:funnelThroughSingleIndexVersion:] + 3171
    29  AppKit                              0x9ba1b9a3 -[NSTableView selectRowIndexes:byExtendingSelection:] + 137
    30  AppKit                              0x9c072a7a -[NSTextViewCompletionController displayCompletions:indexOfSelectedItem:forPartialWordRange:originalString:atPoint:forTextView:] + 4794
    31  AppKit                              0x9c06c791 -[NSTextView(NSKeyBindingCommands) complete:] + 844
    32  libobjc.A.dylib                     0x9488d853 -[NSObject performSelector:withObject:] + 70
    33  AppKit                              0x9bb7baba -[NSResponder doCommandBySelector:] + 91
    34  AppKit                              0x9bb7b93e -[NSTextView doCommandBySelector:] + 152
    35  AppKit                              0x9bb7b887 -[NSTextInputContext(NSInputContext_WithCompletion) doCommandBySelector:completionHandler:] + 114
    36  AppKit                              0x9bb7b80b -[NSTextInputContext doCommandBySelector:] + 61
    37  AppKit                              0x9bb7b6e3 -[NSTextInputContext _handleCommand:] + 96
    38  AppKit                              0x9bb610c3 -[NSKeyBindingManager(NSKeyBindingManager_MultiClients) interpretEventAsCommand:forClient:] + 2336
    39  AppKit                              0x9c1e4b2d __61-[NSTextInputContext _handleEvent:options:completionHandler:]_block_invoke1016 + 364
    40  AppKit                              0x9bb7b7ae __99-[NSTextInputContext tryHandleEvent_HasMarkedText_withDispatchCondition:dispatchWork:continuation:]_block_invoke + 34
    41  AppKit                              0x9bb7b779 __61-[NSTextInputContext _handleEvent:options:completionHandler:]_block_invoke_4 + 26
    42  AppKit                              0x9bb62f39 -[NSTextInputContext(NSInputContext_WithCompletion) hasMarkedTextWithCompletionHandler:] + 72
    43  AppKit                              0x9bb7b758 __61-[NSTextInputContext _handleEvent:options:completionHandler:]_block_invoke_3 + 104
    44  AppKit                              0x9bb741fc -[NSTextInputContext tryHandleEvent_HasMarkedText_withDispatchCondition:dispatchWork:continuation:] + 107
    45  AppKit                              0x9c1e48e3 __61-[NSTextInputContext _handleEvent:options:completionHandler:]_block_invoke1004 + 322
    46  AppKit                              0x9c1e42a3 __125-[NSTextInputContext tryTSMProcessRawKeyEvent:dispatchCondition:setupForDispatch:furtherCondition:dispatchWork:continuation:]_block_invoke + 33
    47  AppKit                              0x9c1e46da __61-[NSTextInputContext _handleEvent:options:completionHandler:]_block_invoke_2994 + 46
    48  HIToolBox                           0x9288ebd9 __TSMProcessRawKeyEventWithOptionsAndCompletionHandler_block_invoke_5 + 86
    49  HIToolBox                           0x9288eb71 __TryKeyDownEventToTSMKeyEvent_WithContinuationHandler_block_invoke + 32
    50  HIToolBox                           0x9288eb44 __TSMKeyEvent_WithCompletionHandler_block_invoke + 26
    51  HIToolBox                           0x9288ead1 __utDeliverTSMEvent_WithCompletionHandler_block_invoke_3 + 50
    52  HIToolBox                           0x9288d518 __SendUnicodeTextAEToUnicodeDoc_WithCompletionHandler_block_invoke_2 + 57
    53  HIToolBox                           0x9288a37f __SendTSMEvent_WithCompletionHandler_block_invoke + 72
    54  HIToolBox                           0x9288d4ca __SendEventToEventTargetWithCompletionHandler_block_invoke + 25
    55  HIToolBox                           0x9288d49b ___ZL23DispatchEventToHandlersP14EventTargetRecP14OpaqueEventRefP14HandlerCallRec_block_invoke + 127
    56  AppKit                              0x9bb6f27c ___NSTSMEventHandler_block_invoke + 25
    57  AppKit                              0x9c1dd0a5 __55-[NSTextInputContext handleTSMEvent:completionHandler:]_block_invoke195 + 2676
    58  AppKit                              0x9bb62fee __102-[NSTextInputContext tryHandleTSMEvent_HasMarkedText_withDispatchCondition:dispatchWork:continuation:]_block_invoke + 34
    59  AppKit                              0x9bb62fb2 __55-[NSTextInputContext handleTSMEvent:completionHandler:]_block_invoke_3 + 26
    60  AppKit                              0x9bb62f39 -[NSTextInputContext(NSInputContext_WithCompletion) hasMarkedTextWithCompletionHandler:] + 72
    61  AppKit                              0x9bb62ee1 __55-[NSTextInputContext handleTSMEvent:completionHandler:]_block_invoke_2 + 104
    62  AppKit                              0x9bb62e3c -[NSTextInputContext tryHandleTSMEvent_HasMarkedText_withDispatchCondition:dispatchWork:continuation:] + 107
    63  AppKit                              0x9bb62ab5 -[NSTextInputContext handleTSMEvent:completionHandler:] + 3364
    64  AppKit                              0x9bb61d2b _NSTSMEventHandler + 302
    65  HIToolBox                           0x929ed5a4 _Z22_InvokeEventHandlerUPPP25OpaqueEventHandlerCallRefP14OpaqueEventRefPvPFlS0_S2_S3_E + 36
    66  HIToolBox                           0x9282b681 _ZL23DispatchEventToHandlersP14EventTargetRecP14OpaqueEventRefP14HandlerCallRec + 2291
    67  HIToolBox                           0x9282a65c _ZL30SendEventToEventTargetInternalP14OpaqueEventRefP20OpaqueEventTargetRefP14HandlerCallRec + 402
    68  HIToolBox                           0x9282a4c3 SendEventToEventTargetWithOptions + 95
    69  HIToolBox                           0x92889ff9 SendTSMEvent_WithCompletionHandler + 451
    70  HIToolBox                           0x9288a6ee __SendUnicodeTextAEToUnicodeDoc_WithCompletionHandler_block_invoke + 569
    71  HIToolBox                           0x9288a49e __SendFilterTextEvent_WithCompletionHandler_block_invoke + 261
    72  HIToolBox                           0x9288a37f __SendTSMEvent_WithCompletionHandler_block_invoke + 72
    73  HIToolBox                           0x9288a061 SendTSMEvent_WithCompletionHandler + 555
    74  HIToolBox                           0x92889dfc SendFilterTextEvent_WithCompletionHandler + 283
    75  HIToolBox                           0x92889a04 SendUnicodeTextAEToUnicodeDoc_WithCompletionHandler + 398
    76  HIToolBox                           0x92889717 __utDeliverTSMEvent_WithCompletionHandler_block_invoke_2 + 317
    77  HIToolBox                           0x92889592 __utDeliverTSMEvent_WithCompletionHandler_block_invoke + 465
    78  HIToolBox                           0x928893b8 TSMKeyEvent_WithCompletionHandler + 648
    79  HIToolBox                           0x928890d7 __TSMProcessRawKeyEventWithOptionsAndCompletionHandler_block_invoke_4 + 288
    80  HIToolBox                           0x92888f63 __TSMProcessRawKeyEventWithOptionsAndCompletionHandler_block_invoke_3 + 336
    81  HIToolBox                           0x92888cc9 __TSMProcessRawKeyEventWithOptionsAndCompletionHandler_block_invoke_2 + 261
    82  HIToolBox                           0x92888ab7 __TSMProcessRawKeyEventWithOptionsAndCompletionHandler_block_invoke + 255
    83  HIToolBox                           0x9286e413 TSMProcessRawKeyEventWithOptionsAndCompletionHandler + 3730
    84  AppKit                              0x9c1e46a4 __61-[NSTextInputContext _handleEvent:options:completionHandler:]_block_invoke993 + 147
    85  AppKit                              0x9bb60652 -[NSTextInputContext tryTSMProcessRawKeyEvent:dispatchCondition:setupForDispatch:furtherCondition:dispatchWork:continuation:] + 129
    86  AppKit                              0x9bb6031d -[NSTextInputContext _handleEvent:options:completionHandler:] + 1708
    87  AppKit                              0x9bb5fc4e -[NSTextInputContext handleEvent:] + 128
    88  AppKit                              0x9bb5fb4b -[NSView interpretKeyEvents:] + 205
    89  AppKit                              0x9bb5f989 -[NSTextView keyDown:] + 686
    90  MyApp                               0x004de011 -[CBAutocompleteTextField keyDown:] + 385
    91  AppKit                              0x9c0e7f9b -[NSWindow _reallySendEvent:isDelayedEvent:] + 8478
    92  AppKit                              0x9b9cb3ca -[NSWindow sendEvent:] + 526
    93  AppKit                              0x9b9c79c4 -[NSApplication sendEvent:] + 4765
    94  MyApp                                0x0004f2a2 -[CBApplication sendEvent:] + 370
    95  AppKit                              0x9b8e7bfc -[NSApplication run] + 1003
    96  AppKit                              0x9b85cfa0 NSApplicationMain + 2082
    97  MyApp                               0x000026fb main + 43
    98  MyApp                               0x00002605 start + 53

我想绑定适用于显示值,但不能编辑它们?

UPDATE
添加了一个符号断点,我得到以下内容

po  *(id *)($esp + 4)
<NSTextValueBinder: 0xfe40720>{object: <NSTableColumn: 0xfe40180>   identifier: MovieReleaseYear,bindings: value=arrangedObjects.MovieReleaseYear}

p  *(SEL *)($esp + 8)
(SEL) $10 = "_valueForKeyPath:ofObject:mode:raisesForNotApplicableKeys:"

po  *(id *)($esp + 12)
arrangedObjects

po  *(id *)($esp + 16)
<CBTreeController: 0x39b4340>[object class: NSMutableDictionary]

解决方法

我最近偶然发现了和你一样的问题.我不确定是否要帮助你,但我仍然会提供适合我的修复方法.

我不知道你的整个代码,所以我不能确定它是否和你一样,但我也是,试图绑定一个列并稍后编辑它,给我同样的崩溃.

事实上这很简单.我在将列添加到Outline视图之前绑定了列,如下所示:

[theEditingColumn bind:@"value" myTreeController withKeyPath:[NSString stringWithFormat:@"arrangedObjects.%@",Metadata.columnBindingKeyPath] options:bindingOptions];
[theOutlineView addTableColumn: theEditingColumn]

我无法解释为什么会出现这种情况,但转换它就把它固定在我身边:

[theOutlineView addTableColumn: theEditingColumn]
[theEditingColumn bind:@"value" myTreeController withKeyPath:[NSString stringWithFormat:@"arrangedObjects.%@",Metadata.columnBindingKeyPath] options:bindingOptions];

猜你在找的C&C++相关文章