-draggingEnded

  • The release notes say "-draggingEnded is now implemented for
    applications linked on Leopard or later." But when I rebuild my app, I
    get

      *** -[CellEditor draggingEnded:]: unrecognized selector sent to
    instance 0x175bc440

    when I send

    [super draggingEnded: aSender];

    So it almost looks like the reverse!

    David Dunham
    Voice/Fax: 206 783 7404            http://www.pensee.com/dunham/
    Imagination is more important than knowledge. -- Albert Einstein
  • NSDraggingSource is an informal protocol, which means it may be
    implemented in some views (like NSTableView) and in other cases you
    may have to implement it yourself. I don't know what CellEditor is,
    but it sure does not sound like a subclass of a view that implements it.

    Christiaan

    On 14 Nov 2007, at 8:28 AM, David Dunham wrote:

    > The release notes say "-draggingEnded is now implemented for
    > applications linked on Leopard or later." But when I rebuild my
    > app, I get
    >
    > *** -[CellEditor draggingEnded:]: unrecognized selector sent to
    > instance 0x175bc440
    >
    > when I send
    >
    > [super draggingEnded: aSender];
    >
    > So it almost looks like the reverse!
    >
    > David Dunham
    > Voice/Fax: 206 783 7404            http://www.pensee.com/dunham/
    > Imagination is more important than knowledge. -- Albert Einstein
  • On 14 Nov 2007, at 01:44, Christiaan Hofman wrote:

    > NSDraggingSource is an informal protocol, which means it may be
    > implemented in some views (like NSTableView) and in other cases you
    > may have to implement it yourself. I don't know what CellEditor is,
    > but it sure does not sound like a subclass of a view that implements
    > it.

    CellEditor is my class, and I do implement draggingEnded:. The
    exception comes when I call super (an NSTextView).

    It's even worse -- I changed the code to

    - (void) draggingEnded: (id <NSDraggingInfo>) aSender
    // ...
    if ([super respondsToSelector: @selector(draggingEnded:)])
      [super draggingEnded: aSender];

    and still get unrecognized selector.

    David Dunham
    Voice/Fax: 206 783 7404            http://www.pensee.com/dunham/
    Imagination is more important than knowledge. -- Albert Einstein

    David Dunham    A Sharp, LLC
    Voice/Fax: 206 783 7404    http://a-sharp.com
    Efficiency is intelligent laziness.
  • On 14 Nov 2007, at 4:52 PM, David Dunham wrote:

    >
    > On 14 Nov 2007, at 01:44, Christiaan Hofman wrote:
    >
    >> NSDraggingSource is an informal protocol, which means it may be
    >> implemented in some views (like NSTableView) and in other cases
    >> you may have to implement it yourself. I don't know what
    >> CellEditor is, but it sure does not sound like a subclass of a
    >> view that implements it.
    >
    >
    > CellEditor is my class, and I do implement draggingEnded:. The
    > exception comes when I call super (an NSTextView).
    >
    > It's even worse -- I changed the code to
    >
    > - (void) draggingEnded: (id <NSDraggingInfo>) aSender
    > // ...
    > if ([super respondsToSelector: @selector(draggingEnded:)])
    > [super draggingEnded: aSender];
    >
    > and still get unrecognized selector.
    >

    That code is totally wrong. It does not check whether the superclass
    implements draggingEnded:, it just uses the superclass's
    implementation of -respondsToSelector: to check whether the object
    itself implements it ('super' does not change the receiver, only the
    method implementation). As this is the same as self's implementation,
    your code is equivalent to:

    - (void) draggingEnded: (id <NSDraggingInfo>) aSender
    // ...
    if ([self respondsToSelector: @selector(draggingEnded:)])
      [super draggingEnded: aSender];

    and as you're guaranteed to implement to draggingEnded: it is
    equivalent to:

    - (void) draggingEnded: (id <NSDraggingInfo>) aSender
    // ...
    if (YES)
      [super draggingEnded: aSender];

    So it's no wonder it will fail. You should do this:

    if ([[CellEditor superclass] instancesRespondToSelector:_cmd])
      [super draggingEnded: aSender];

    As a general remark on your question, note that the release notes do
    not say *where* draggingEnded: is implemented, only that it is
    implemented *somewhere*. Certainly, it is not implemented everywhere
    (i.e. in NSObject). Maybe it is only *called* at the correct time
    now? I agree they should have indicated what they mean with this
    sentence, because it basically contains no information.

    Christiaan

    > David Dunham
    > Voice/Fax: 206 783 7404            http://www.pensee.com/dunham/
    > Imagination is more important than knowledge. -- Albert Einstein
    >
    >
    > David Dunham    A Sharp, LLC
    > Voice/Fax: 206 783 7404    http://a-sharp.com
    > Efficiency is intelligent laziness.
    >
    > _______________________________________________
    > MacOSX-dev mailing list
    > <MacOSX-dev...>
    > http://www.omnigroup.com/mailman/listinfo/macosx-dev
  • On 14 Nov 2007, at 08:10, Christiaan Hofman wrote:

    > You should do this:
    >
    > if ([[CellEditor superclass] instancesRespondToSelector:_cmd])
    > [super draggingEnded: aSender];

    Thanks, that worked (under Leopard).

    > As a general remark on your question, note that the release notes do
    > not say *where* draggingEnded: is implemented, only that it is
    > implemented *somewhere*. Certainly, it is not implemented everywhere
    > (i.e. in NSObject). Maybe it is only *called* at the correct time
    > now? I agree they should have indicated what they mean with this
    > sentence, because it basically contains no information.

    FWIW, my original code (without any test, simply passing dragginEnded:
    on to super) worked fine in Tiger.

    David Dunham    A Sharp, LLC
    Voice/Fax: 206 783 7404    http://a-sharp.com
    Efficiency is intelligent laziness.
  • On Nov 14, 2007 7:11 PM, Christiaan Hofman <cmhofman...> wrote:
    >
    > On 14 Nov 2007, at 5:35 PM, David Dunham wrote:
    >
    >> On 14 Nov 2007, at 08:10, Christiaan Hofman wrote:
    >>
    >>> You should do this:
    >>>
    >>> if ([[CellEditor superclass] instancesRespondToSelector:_cmd])
    >>> [super draggingEnded: aSender];
    >>
    >> Thanks, that worked (under Leopard).
    >>
    >>> As a general remark on your question, note that the release notes
    >>> do not say *where* draggingEnded: is implemented, only that it is
    >>> implemented *somewhere*. Certainly, it is not implemented
    >>> everywhere (i.e. in NSObject). Maybe it is only *called* at the
    >>> correct time now? I agree they should have indicated what they
    >>> mean with this sentence, because it basically contains no
    >>> information.
    >>
    >>
    >> FWIW, my original code (without any test, simply passing
    >> dragginEnded: on to super) worked fine in Tiger.
    >>
    >> David Dunham    A Sharp, LLC
    >> Voice/Fax: 206 783 7404    http://a-sharp.com
    >> Efficiency is intelligent laziness.
    >
    > Are you sure? The only AppKit objects implementing it seem to be
    > related to tokens.
    >
    > Christiaan
    >
    >

    Well I think I understand. It's what the cryptic sentence in the
    release notes really mean: on Tiger draggingEnded: is actually never
    called. So the fact that your code didn't crash on Tiger is actually a
    bug, that was fixed in Leopard! The code is buggy both on Tiger and
    Leopard (as the meaning of "super", "respondsToSelector:", and
    "informal protocol" have not changed).

    Christiaan
previous month november 2007 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    
Go to today