Re: Bindings Concept Question
Re: Bindings Concept Question
- Subject: Re: Bindings Concept Question
- From: Ken Thomases <email@hidden>
- Date: Sat, 21 Jun 2008 18:24:23 -0500
On Jun 21, 2008, at 12:49 PM, Alex Wait wrote:
I have tried to, in my init method, to do this
id proxy = [controller mutableArrayValueForKey:@"arrayOfData"];
I have also tried using the values "firstName" and "lastName" which
are the
properties of my Data class. controller is a pointer
to my array controller.
In the init method of the same class which holds the arrayOfData
property? If so, then you want to send mutableArrayValueForKey: to
self, not to controller.
If you're thinking of using the resulting proxy during the init
method, then that's not necessary. Until the object is initialized,
it can't have any observers.
If you're planning to keep the proxy around for use during addData:,
then you'd need to store it in an instance variable rather than a
local variable and, if you're not using garbage collection, retain
it. (I figure you probably know about the instance vs. local thing,
but just thought I'd be thorough.)
however proxy is nil.
Hmm. That's odd. I wouldn't think that method would be capable of
returning nil. It's documented as succeeding or throwing an
exception. I suspect "controller" is nil at this point, and messages
to nil generally result in nil. This is probably a case of an outlet
configured in a nib, which is not set up at init time. It's connected
after init and before -awakeFromNib.
Since controller isn't the proper receiver of this message anyway, no
need to worry too deeply about this. Send the message to self, and
this will probably work itself out.
If I am able to get a proxy object, can I do modifications and still
have
KVO notifications sent?
Yup, that's what it's for. If you do the modifications to the proxy,
KVO notifications will be sent.
After reading the responses I am sure that this method is not adding
the
data in the way that means KVO notifciations would be sent.
Correct, the implementation you posted would fail to send KVO
notifications.
Cheers,
Ken
_______________________________________________
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