Re: Why is compiler warning for +setKeys:triggerChangeNotificationsForDependentKey: ??
Re: Why is compiler warning for +setKeys:triggerChangeNotificationsForDependentKey: ??
- Subject: Re: Why is compiler warning for +setKeys:triggerChangeNotificationsForDependentKey: ??
- From: Steve Cronin <email@hidden>
- Date: Tue, 20 Apr 2010 21:10:33 -0500
Graham;
Directly from the current Apple docs:Key-Value Observing Programming Guide
No mention of deprecation…
Registering Dependent Keys
It’s common that the value of one property of a class is dependent on the value of another property of the same class. Key-value observing provides a lightweight method of declaring these dependencies through the use of the class method setKeys:triggerChangeNotificationsForDependentKey:.
The setKeys:triggerChangeNotificationsForDependentKey: class method specifies an array of keys that will cause a change notification to be triggered for the dependent key.
Consider the case of a method that returns a person’s full name by combining the first and last names. The fullNameproperty is dependent on both the firstName property and the lastName property. Anytime the value of firstName orlastName changes, an observer notification must be sent for the fullName property. The example in Listing 1 registers this dependency and implements the accessor method for the fullName, firstName and lastName properties.
Listing 1 Registering a dependent key
+ (void)initialize {
[self setKeys:[NSArray arrayWithObjects:@"firstName",@"lastName",nil]
triggerChangeNotificationsForDependentKey:@"fullName"];
}
On Apr 20, 2010, at 8:53 PM, Graham Cox wrote:
>
> On 21/04/2010, at 11:48 AM, Steve Cronin wrote:
>
>> I'm seeing compiler warnings -> : warning: 'ABC' may not respond to '+setKeys:triggerChangeNotificationsForDependentKey:'
>>
>> What have I overlooked?
>
>
> As a method that has been deprecated for a long time, perhaps it's no longer being included in the headers of your current SDK?
>
> --Graham
>
>
_______________________________________________
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