Search code examples
objective-ciphonereferencekey-value-coding

iPhone - setValue:forkey: not documented


I have these lines in my code :

[defaults setValue:someValue forKey:@"someValue"];
[animationGroup setValue:@"someValue" forKey:@"someValue"];  // CAAnimationGroup
NSString* animName = [theAnimation valueForKey:@"someValue"]; // CAAnimation

But reading the Apple Reference Documentation :

I don't see any reference to these methods, even parsing hierarchy or conformed protocols. From where do they come ? Is their use allowed ?


Solution

  • These are Key-Value Coding methods; if those classes are Key-Value Coding compliant for those keys, then you can use them without issue. With respect to Core Animation, both CALayer and CAAnimation are KVC compliant, as detailed in this programming guide. For more general information, refer to the NSKeyValueCoding informal protocol and the Key-Value Coding Programming Guide.