Re: Question about notifying KVO observers of changes to a property.
Re: Question about notifying KVO observers of changes to a property.
- Subject: Re: Question about notifying KVO observers of changes to a property.
- From: Morales Vivó Óscar <email@hidden>
- Date: Thu, 21 May 2009 20:43:53 -0400
Good point. The problem I'm having is that I don't know when to call
the "willChange…" method, only that sometimes I need to call the
"didChange…" one.
On May 21, 2009, at 16:34 , Peter Duniho wrote:
On May 21, 2009, at 11:33 AM, Morales Vivó Óscar wrote:
I have an cocoa controller object with a property that is actually
read from another, C++ object. It works fine when updating or
reading the value, but sometimes other C++ parts of the program
will change the value of the property and there's no good way to
notify the cocoa controller object of the change.
I wanted to know if it's an issue from, elsewhere in the program,
just call the object's willChangeValueForKey: and
didChangeValueForKey: for a property that automatically notifies
when directly changed, or if there's a more immediate and
officially sanctioned way of letting an object know that it should
notify its observers that one of its properties has changed its
value.
Sorry if this is a silly question, but...
If you are able to call the associated KVO methods
(willChangeValueForKey:, didChangeValueForKey:), why can't you just
call the property setter?
I understand that if you've got data changing only within the C++,
propagating that back to the Obj-C object requires extra work. But
if you know when to call the KVO methods, surely you're already
propagating it somehow. Seems like you could at that point just use
the Obj-C object's setter instead of setting it internally to the C+
+ and calling the KVO methods directly.
Pete_______________________________________________
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
_______________________________________________
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