Instance not responding to selector

  • I have a set of plugins which I load via a custom framework.  The plugins load and behave correctly in the UI.

    I have a set of corresponding "rule" objects, one for each class of plugin. A plugin may load data from a rule, and a rule may load data from a plugin:  -[RSRule loadFromPlugin:(RSPlugin*)plugin]  or -[RSPlugin loadFromRule:(RSRule*)rule].  I have moved away from using categories to do this and the classes implement these methods internally.  The header files list the methods correctly.

    However, after a clean and build, attempting to invoke any of these -[loadFrom..:] methods causes a crash reporting "unrecognized selector".

    A typical error message:

    2012-07-10 20:42:39.791 Trixie[41453:303] -[RSReactionRule loadFromPlugin:]: unrecognized selector sent to instance 0x1018961b0
    2012-07-10 20:42:39.792 Trixie[41453:303] -[RSReactionRule loadFromPlugin:]: unrecognized selector sent to instance 0x1018961b0
    2012-07-10 20:42:39.794 Trixie[41453:303] (
    0  CoreFoundation                      0x00007fff898bf716 __exceptionPreprocess + 198
    1  libobjc.A.dylib                    0x00007fff858a5470 objc_exception_throw + 43
    2  CoreFoundation                      0x00007fff89955d5a -[NSObject(NSObject) doesNotRecognizeSelector:] + 186
    3  CoreFoundation                      0x00007fff898adc3e ___forwarding___ + 414
    4  CoreFoundation                      0x00007fff898ada28 _CF_forwarding_prep_0 + 232
    5  Trixie                              0x000000010000adf3 -[RSRuleWindowController addRuleToStore:] + 131
    6  AppKit                              0x00007fff8a4b2599 -[NSApplication sendAction:to:from:] + 342
    7  AppKit                              0x00007fff8a4b23f7 -[NSControl sendAction:to:] + 85
    8  AppKit                              0x00007fff8a4b232b -[NSCell _sendActionFrom:] + 138
    9  AppKit                              0x00007fff8a4b0813 -[NSCell trackMouse:inRect:ofView:untilMouseUp:] + 1855
    10  AppKit                              0x00007fff8a4b0061 -[NSButtonCell trackMouse:inRect:ofView:untilMouseUp:] + 504
    11  AppKit                              0x00007fff8a4af7dc -[NSControl mouseDown:] + 820
    12  AppKit                              0x00007fff8a4a713e -[NSWindow sendEvent:] + 6853
    13  AppKit                              0x00007fff8a4a3274 -[NSApplication sendEvent:] + 5761
    14  AppKit                              0x00007fff8a3b8eaa -[NSApplication run] + 636
    15  AppKit                              0x00007fff8a35d886 NSApplicationMain + 869
    16  Trixie                              0x00000001000012a2 main + 34
    17  libdyld.dylib                      0x00007fff8890b7e1 start + 0
    )

    Any advice on how I could narrow down what is causing this? I have tried using repondsToSelector: but this doesn't do anything but confirm what the error message states, that the selector is not recognized.

    ~ Erik
  • On Jul 10, 2012, at 9:03 PM, Erik Stainsby <erik.stainsby...> wrote:

    > 2012-07-10 20:42:39.792 Trixie[41453:303] -[RSReactionRule loadFromPlugin:]: unrecognized selector sent to instance 0x1018961b0

    What does the implementation of the -loadFromPlugin: method in that class (or a superclass it inherits it from) look like? Not the body, just the outside part.

    —Jens
  • On 10 Jul 2012, at 11:03 PM, Erik Stainsby wrote:

    > Any advice on how I could narrow down what is causing this? I have tried using repondsToSelector: but this doesn't do anything but confirm what the error message states, that the selector is not recognized.

    More than that, it states that the selector is not recognized _by RSReactionRule_. Are you sending that message to an RSReactionRule? If you don't think you are, set a breakpoint (presumably somewhere in -addRuleToStore:), and examine the recipient of that message; does the debugger think it's an RSReactionRule?

    There are two main reasons an object won't recognize a selector.

    - You blundered and wrote code that sent the selector to the wrong object. This is fairly obvious, and the compiler usually urges you not to do it anyway.

    - You sent the message via an object pointer that _used_ to point to a legitimate receiver for the selector, but that object had been deallocated, and the address recycled for another object (an RSReactionRule) that doesn't implement it. In other words, the object got (over)released out from under you. Audit your memory management (better, adopt ARC). The Allocations instrument, set to record reference counts and enabling zombie detection, should help you track this down.

    Or, maybe there's something esoteric going on with your plugin loading. But I'd look at these two possibilities first.

    — F

    --
    Fritz Anderson -- Xcode 4 Unleashed: Hot on the heels of what Apple has been doing with provisioning! -- <http://x4u.manoverboard.org/>
  • On 2012-07-10, at 9:44 PM, Jens Alfke <jens...> wrote:

    >
    > On Jul 10, 2012, at 9:03 PM, Erik Stainsby <erik.stainsby...> wrote:
    >
    >> 2012-07-10 20:42:39.792 Trixie[41453:303] -[RSReactionRule loadFromPlugin:]: unrecognized selector sent to instance 0x1018961b0
    >
    > What does the implementation of the -loadFromPlugin: method in that class (or a superclass it inherits it from) look like? Not the body, just the outside part.
    >
    > —Jens

    #import "RSTrixiePlugin.h"
    @class RSReactionRule;

    @interface RSReactionPlugin : RSTrixiePlugin

    // various properties

    - (void) loadFromRule: (RSReactionRule*) rule;

    @end

    #import "RSReactionPlugin.h"
    #import "RSReactionRule.h"
    @implementation RSReactionPlugin

    - (void) loadFromRule: (RSReactionRule*) rule {
    // setting various properties of the plugin
    }

    @end
  • Hi Fritz,

    I should have stated that I am building against 10.8, and using ARC, and using Xcode 4.4DP6. I don't believe the issues I'm facing are all that esoteric so I don't think the version of XC is likely to effect this situation.

    On 2012-07-10, at 10:02 PM, Fritz Anderson <fritza...> wrote:

    > On 10 Jul 2012, at 11:03 PM, Erik Stainsby wrote:
    >
    >> Any advice on how I could narrow down what is causing this? I have tried using repondsToSelector: but this doesn't do anything but confirm what the error message states, that the selector is not recognized.
    >
    > More than that, it states that the selector is not recognized _by RSReactionRule_. Are you sending that message to an RSReactionRule? If you don't think you are, set a breakpoint (presumably somewhere in -addRuleToStore:), and examine the recipient of that message; does the debugger think it's an RSReactionRule?

    The object which is failing to respond is of the correct class: RSReactionRule in this case, generally an RSTrixieRule subclass. The object is newly allocated and initialized. It has not been sent any other messages at the point of failure.

    RSReactionRule *    reactionRule    = [[RSReactionRule alloc] init];
    [reactionRule loadFromPlugin:(RSReactionPlugin*)self.reactionPlugin];

    > There are two main reasons an object won't recognize a selector.
    >
    > - You blundered and wrote code that sent the selector to the wrong object. This is fairly obvious, and the compiler usually urges you not to do it anyway.

    I believe I have sent it to the correct object.

    > - You sent the message via an object pointer that _used_ to point to a legitimate receiver for the selector, but that object had been deallocated, and the address recycled for another object (an RSReactionRule) that doesn't implement it. In other words, the object got (over)released out from under you. Audit your memory management (better, adopt ARC). The Allocations instrument, set to record reference counts and enabling zombie detection, should help you track this down.

    I am using ARC and have no reason to believe that ARC has reclaimed my newly instantiated object. Calling on it for a description in NSLog statements results in a coherent description being logged. So something of the correct class is at the other end of the pointer being referenced.

    > Or, maybe there's something esoteric going on with your plugin loading. But I'd look at these two possibilities first.

    The plugin loading seems straightforward.  I create a loader from the framework, iterate over the plugins found in my apps' Plugins folder, instantiate and store the plugins in an array. When they have been loaded, I set the loader nil.  Each plugin has a UI component which loads in its correct place and exhibits all the behaviour I expect it to.  It just doesn't;t seem to me that there is room for subtle errors here. I'd be happy to post loader code if that seems likely to anyone.

    ~ Erik
  • On Jul 10, 2012, at 23:11 , Erik Stainsby wrote:

    > @interface RSReactionPlugin : RSTrixiePlugin
    >
    > // various properties
    >
    > - (void) loadFromRule: (RSReactionRule*) rule;
    >
    > @end

    Are you sure that's what you mean? According to this you implemented 'loadFromRule:' but according to your log you invoke 'loadFromPlugin:'.
  • On 11 Jul 2012, at 1:33 AM, Erik Stainsby wrote:

    > I should have stated that I am building against 10.8, and using ARC, and using Xcode 4.4DP6

    Then I can't help. Aside from the fact that my problem-solving technique* would require me to sit down for an hour or two and grope around your project by hand, those products are still under nondisclosure.

    * (Others, with direct experience and better imaginations, may be more effective.)

    I know it's hairsplitting, given that what's currently on the servers is likely to be identical to what will be public in a week or two, but that's where the line is drawn.

    — F

    --
    Fritz Anderson -- Xcode 4 Unleashed: Now in stores! -- <http://x4u.manoverboard.org/>
  • On 2012-07-10, at 11:47 PM, Quincey Morris <quinceymorris...> wrote:

    > On Jul 10, 2012, at 23:11 , Erik Stainsby wrote:
    >
    >> @interface RSReactionPlugin : RSTrixiePlugin
    >>
    >> // various properties
    >>
    >> - (void) loadFromRule: (RSReactionRule*) rule;
    >>
    >> @end
    >
    > Are you sure that's what you mean? According to this you implemented 'loadFromRule:' but according to your log you invoke 'loadFromPlugin:'.

    My error, this is the other side of the symmetric relationship.

    @interface RSReactionRule : RSTrixieRule

    // various properties

    -(void) loadFromPlugin: (RSReactionPlugin*) plugin;

    @end
  • On 2012-07-11, at 7:13 AM, Fritz Anderson <fritza...> wrote:

    > On 11 Jul 2012, at 1:33 AM, Erik Stainsby wrote:
    >
    >> I should have stated that I am building against 10.8, and using ARC, and using Xcode 4.4DP6
    >
    > Then I can't help. Aside from the fact that my problem-solving technique* would require me to sit down for an hour or two and grope around your project by hand, those products are still under nondisclosure.
    >
    > * (Others, with direct experience and better imaginations, may be more effective.)
    >
    > I know it's hairsplitting, given that what's currently on the servers is likely to be identical to what will be public in a week or two, but that's where the line is drawn.
    >
    > — F

    The build results behave exactly the same when I switch the target to 10.7
  • On Jul 10, 2012, at 11:11 PM, Erik Stainsby <erik.stainsby...> wrote:

    > - (void) loadFromRule: (RSReactionRule*) rule;

    The method I was asking about is -[RSReactionRule loadFromPlugin:].

    —Jens
previous month july 2012 next month
MTWTFSS
            1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31          
Go to today