Bindings with GB outside of IB?

  • When working with a custom view in IB, we don't have the luxury of
    using the pallet interface for our bindings. If I need to bind a
    custom view to, say, the arranged objects of an array controller, I
    usually make an outlet for the controller in my view, connect it, and
    then in my view implement the full suite of...

    -bind:toObject:withKeyPath:options: that sends...
    -addObserver:forKeyPath:options:context: to my array controller outlet
    so that...
    -observeValueForKeyPath:ofObject:change:context: gets notified of
    changes. Oh, and...
    -unbind: to tear everything down and remove those observers.

    I seem to recall that, with GC enabled, I no longer have to worry
    about unregistering observers as they get zeroed out automagically
    when collected? Does this mean I can safely tear out most of this
    cruft? Seeing as I have an outlet to the controller I want to bind to,
    can't I just -addObserver:forKeyPath:options:context: in -awakeFromNib
    and use -observeValueForKeyPath:ofObject:change:context: to grab new
    values from my outlet?

    To put it another way, has garbage collection/Obj-C 2.0 changed the
    way we're supposed to implement the binding pattern in our custom
    objects?

    Cheers,
    -Joshua Emmons
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