Re: Inter-class Dependent Keys
Re: Inter-class Dependent Keys
- Subject: Re: Inter-class Dependent Keys
- From: glenn andreas <email@hidden>
- Date: Sat, 5 Mar 2005 09:15:31 -0600
On Mar 5, 2005, at 8:52 AM, Jonathon Mah wrote:
On 6 Mar 2005, at 00:43, Ricky Sharp wrote:
A common example is one where your model has two properties: lastName
and firstName. Along with supplying accessors for those properties,
it also supplies a getter for a fullName (derived) property. Since
fullName depends on both lastName and firstName, you'd do this
(typically within your model's +initialize):
I understand this. I'm comfortable with +[NSObject
setKeys:triggerChangeNotificationsForDependentKey:]. It works within a
class. The situation I'm trying to work out is, for example, when
firstName and lastName are stored in one class, and fullName (the
dependent key) in a different class.
The second classes instances would register themselves as being
dependent on firstName and lastName in the first object.
Then, in the second classes observeValueForKeyPath method, if the
keypat is "firstName" or "lastName" (and the object is the first
object), it would just do
[self willChangeValueForKey: @"fullName"];
[self didChangeValueForKey: @"fullName"];
You could also register for the changes in the first object, and then
say [secondObject will/didChangeValueForKey: @"fullName"].
Regardless, you're going to need some sort of reference between the
two object, and this isn't going to be as clean as the intra-class
dependancy (since between classes the dependancy is actually between
two different objects, instead of just the instance and itself).
Glenn Andreas email@hidden
<http://www.gandreas.com/> oh my!
Mad, Bad, and Dangerous to Know
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden