NSObject's bind:toObject:forKeyPath:options

  • What does NSObject's implementation of
    bind:toObject:forKeyPath:options: do?

    Should my class' implementation of it call it on its superclass?

    Thanks,
    Mike

    Sent while mobile.
  • on 11/24/07 1:26 AM, <alephx01...> purportedly said:

    > What does NSObject's implementation of
    > bind:toObject:forKeyPath:options: do?
    >
    > Should my class' implementation of it call it on its superclass?

    I would ask, why do you feel the need to override the method? Binding
    structures have introspection, if you needed that. Otherwise, I would say,
    yes, if you override it, you should call the method on super.

    Best,

    Keary Suska
    Esoteritech, Inc.
    "Demystifying technology for your home or business"
  • Well, for one, Apple's own "joystick" example overrides it:

    http://developer.apple.com/documentation/Cocoa/Conceptual/CocoaBindings/Con
    cepts/HowDoBindingsWork.html


    > on 11/24/07 1:26 AM, Keary Suska purportedly said:
    >
    >> What does NSObject's implementation of
    >> bind:toObject:forKeyPath:options: do?
    >>
    >> Should my class' implementation of it call it on its superclass?
    >
    >
    > I would ask, why do you feel the need to override the method? Binding
    > structures have introspection, if you needed that. Otherwise, I
    > would say,
    > yes, if you override it, you should call the method on super.
    >
    > Best,
    >
    > Keary Suska
    > Esoteritech, Inc.
    > "Demystifying technology for your home or business"
  • I believe NSObject's implementation works roughly as follows...

    - (void)bind:(NSString *)binding toObject:(id)model withKeyPath:
    (NSString *)path options:(NSDictionary *)options;

    An auxiliary object is created which is registered as an observer of
    the given key path of the given model object; In response to
    observation, the auxiliary object invokes -setValue:forKey: on the
    original receiver; -unbind: removes the observation and releases the
    auxiliary object.  If you don't call super then you'll also have to
    override -infoForBinding:

    Cheers,
    dave

    On 24-Nov-07, at 7:38 PM, Mike R. Manzano wrote:

    > Well, for one, Apple's own "joystick" example overrides it:
    >
    > http://developer.apple.com/documentation/Cocoa/Conceptual/CocoaBindings/Con
    cepts/HowDoBindingsWork.html

    >
    >
    >> on 11/24/07 1:26 AM, Keary Suska purportedly said:
    >>
    >>> What does NSObject's implementation of
    >>> bind:toObject:forKeyPath:options: do?
    >>>
    >>> Should my class' implementation of it call it on its superclass?
    >>
    >>
    >> I would ask, why do you feel the need to override the method? Binding
    >> structures have introspection, if you needed that. Otherwise, I
    >> would say,
    >> yes, if you override it, you should call the method on super.
    >>
    >> Best,
    >>
    >> Keary Suska
    >> Esoteritech, Inc.
    >> "Demystifying technology for your home or business"
  • on 11/24/07 7:38 PM, <alephx01...> purportedly said:

    > Well, for one, Apple's own "joystick" example overrides it:
    >
    > http://developer.apple.com/documentation/Cocoa/Conceptual/CocoaBindings/Con
    cep

    > ts/HowDoBindingsWork.html

    I believe in this case they are being merely illustrative. You get bindings
    support for free. You only need to override the method when you need
    additional behavior, which is uncommon, IMHO. Hence, the question.

    >> on 11/24/07 1:26 AM, Keary Suska purportedly said:
    >>
    >>> What does NSObject's implementation of
    >>> bind:toObject:forKeyPath:options: do?
    >>>
    >>> Should my class' implementation of it call it on its superclass?
    >>
    >>
    >> I would ask, why do you feel the need to override the method? Binding
    >> structures have introspection, if you needed that. Otherwise, I
    >> would say,
    >> yes, if you override it, you should call the method on super.

    Keary Suska
    Esoteritech, Inc.
    "Demystifying technology for your home or business"
  • On Nov 24, 2007, at 12:26 AM, Mike R. Manzano wrote:

    > What does NSObject's implementation of
    > bind:toObject:forKeyPath:options: do?
    >
    > Should my class' implementation of it call it on its superclass?

    It should if it doesn't recognize the passed-in binding name. See the
    comments in the override of it in Leopard /Developer/Examples/AppKit/
    Sketch/SKTGraphicView.m.

    David's summary of what the default implementation does was spot on.
    SKTGraphicView shows an example where that default implementation
    isn't good enough though. It has to override -unbind: too, to match.

        -- Mark
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