Issue #108 resolved

[__NSCFType controlTextDidChange:]: unrecognized selector sent to instance

Jarrad Hope
created an issue

Unsure how to set delegates? All examples online use NibClassBuilder, which no longer exists in pyobjc-3.0.x branch? I'm running 10.9 if that helps, Xcode 6.1.1

class CommandTextDelegate(NSObject):
    def controlTextDidChange_(s, notification):
        print 'controlTextDidChange_'

# ...

commandTextField = objc.IBOutlet()

# ...

delegate = CommandTextDelegate.alloc().init()
self.commandTextField.setDelegate_(delegate)

I tried creating a NSObject custom class in Interface Builder and setting delegate of TextField to it. I also tried removing this and setting delegate manually using the above code

Results in

Dec  5 01:44:03 LearnPyObjC[41569] <Notice>: 2014-12-05 01:44:03.477 LearnPyObjC[41569:507] -[PyObjCAppHelperRunLoopStopper controlTextDidChange:]: unrecognized selector sent to instance 0x1088c93d0
Dec  5 01:44:03 LearnPyObjC[41569] <Notice>: 2014-12-05 01:44:03.478 LearnPyObjC[41569:507] (
Dec  5 01:44:03 LearnPyObjC[41569] <Notice>:    0   CoreFoundation                      0x00007fff94c5625c __exceptionPreprocess + 172
Dec  5 01:44:03 LearnPyObjC[41569] <Notice>:    1   libobjc.A.dylib                     0x00007fff92e80e75 objc_exception_throw + 43
Dec  5 01:44:03 LearnPyObjC[41569] <Notice>:    2   CoreFoundation                      0x00007fff94c5912d -[NSObject(NSObject) doesNotRecognizeSelector:] + 205
Dec  5 01:44:03 LearnPyObjC[41569] <Notice>:    3   CoreFoundation                      0x00007fff94bb4272 ___forwarding___ + 1010
Dec  5 01:44:03 LearnPyObjC[41569] <Notice>:    4   CoreFoundation                      0x00007fff94bb3df8 _CF_forwarding_prep_0 + 120
Dec  5 01:44:03 LearnPyObjC[41569] <Notice>:    5   CoreFoundation                      0x00007fff94c24e0c __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ + 12
Dec  5 01:44:03 LearnPyObjC[41569] <Notice>:    6   CoreFoundation                      0x00007fff94b1882d _CFXNotificationPost + 2893
Dec  5 01:44:03 LearnPyObjC[41569] <Notice>:    7   Foundation                          0x00007fff8d6a8e4a -[NSNotificationCenter postNotificationName:object:userInfo:] + 68
Dec  5 01:44:03 LearnPyObjC[41569] <Notice>:    8   CoreFoundation                      0x00007fff94c24e0c __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ + 12
Dec  5 01:44:03 LearnPyObjC[41569] <Notice>:    9   CoreFoundation                      0x00007fff94b1882d _CFXNotificationPost + 2893
Dec  5 01:44:03 LearnPyObjC[41569] <Notice>:    10  Foundation                          0x00007fff8d6a8e4a -[NSNotificationCenter postNotificationName:object:userInfo:] + 68
Dec  5 01:44:03 LearnPyObjC[41569] <Notice>:    11  AppKit                              0x00007fff8af001b4 -[NSTextView(NSSharing) didChangeText] + 345
Dec  5 01:44:03 LearnPyObjC[41569] <Notice>:    12  AppKit                              0x00007fff8aefd2c2 -[NSTextView insertText:replacementRange:] + 2325
Dec  5 01:44:03 LearnPyObjC[41569] <Notice>:    13  AppKit                              0x00007fff8aefb978 -[NSTextInputContext handleTSMEvent:] + 8271
Dec  5 01:44:03 LearnPyObjC[41569] <Notice>:    14  AppKit                              0x00007fff8aef9905 _NSTSMEventHandler + 205
Dec  5 01:44:03 LearnPyObjC[41569] <Notice>:    15  HIToolbox                           0x00007fff8f5651d4 _ZL23DispatchEventToHandlersP14EventTargetRecP14OpaqueEventRefP14HandlerCallRec + 892
Dec  5 01:44:03 LearnPyObjC[41569] <Notice>:    16  HIToolbox                           0x00007fff8f564787 _ZL30SendEventToEventTargetInternalP14OpaqueEventRefP20OpaqueEventTargetRefP14HandlerCallRec + 385
Dec  5 01:44:03 LearnPyObjC[41569] <Notice>:    17  HIToolbox                           0x00007fff8f578880 SendEventToEventTarget + 40
Dec  5 01:44:03 LearnPyObjC[41569] <Notice>:    18  HIToolbox                           0x00007fff8f5b9d0d SendTSMEvent + 33
Dec  5 01:44:03 LearnPyObjC[41569] <Notice>:    19  HIToolbox                           0x00007fff8f5b989b SendUnicodeTextAEToUnicodeDoc + 473
Dec  5 01:44:03 LearnPyObjC[41569] <Notice>:    20  HIToolbox                           0x00007fff8f5b9595 TSMKeyEvent + 546
Dec  5 01:44:03 LearnPyObjC[41569] <Notice>:    21  HIToolbox                           0x00007fff8f5a62b7 TSMProcessRawKeyEvent + 3807
Dec  5 01:44:03 LearnPyObjC[41569] <Notice>:    22  AppKit                              0x00007fff8aef9150 -[NSTextInputContext handleEvent:] + 731
Dec  5 01:44:03 LearnPyObjC[41569] <Notice>:    23  AppKit                              0x00007fff8aed89dd -[NSView interpretKeyEvents:] + 180
Dec  5 01:44:03 LearnPyObjC[41569] <Notice>:    24  AppKit                              0x00007fff8aef8d6d -[NSTextView keyDown:] + 658
Dec  5 01:44:03 LearnPyObjC[41569] <Notice>:    25  AppKit                              0x00007fff8aea556b -[NSWindow sendEvent:] + 1843
Dec  5 01:44:03 LearnPyObjC[41569] <Notice>:    26  AppKit                              0x00007fff8ae46b32 -[NSApplication sendEvent:] + 3395
Dec  5 01:44:03 LearnPyObjC[41569] <Notice>:    27  AppKit                              0x00007fff8ac969f9 -[NSApplication run] + 646
Dec  5 01:44:03 LearnPyObjC[41569] <Notice>:    28  _objc.so                            0x00000001039c1787 ffi_call_unix64 + 79
Dec  5 01:44:03 LearnPyObjC[41569] <Notice>:    29  ???                                 0x00007fff5fbfb980 0x0 + 140734799788416

Any Ideas on what I'm doing wrong?

Comments (4)

  1. Ronald Oussoren repo owner

    The examples in PyObjC's documentation don't use NibClassBuilder anymore, mostly because NibClassBuilder cannot work with modern tools (AFAIC it stopped working with Xcode 4).

    The code above looks OK, but there's not enough code to be entirely sure.

  2. Log in to comment