Bindings with GB outside of IB?
Bindings with GB outside of IB?
- Subject: Bindings with GB outside of IB?
- From: Joshua Emmons <email@hidden>
- Date: Wed, 7 Nov 2007 22:01:50 -0600
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
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden