Hi,
How different is the behavior of CALayer's valueForKey from that of any other ordinary NSObject's?
I have a custom layer which inherits from CALayer, and that has a property named 'angle',
but [myLayer valueForKey: @"angle"] always returns nil while [myLayer angle] returns the right value.
ValueForKey: works as intended with a class inherited from NSObject, but not one from CALayer, so I guess it's [CALayer valueForKey:] that's doing some strange tricks..
Thanks!
views:
49answers:
1
+1
A:
The whole Core Animation is actually backed by C++ code, the interface is just an Objective-C wrapper. Therefore, functions like -valueForKey:
has been reimplemented to go through the C++ core first. This is the difference from NSObject.
If your -angle
is just a method, not a declared property, the custom -valueForKey:
won't find it. This is likely a bug. Try to make sure you declare a property .angle
.
@property(assign) float angle;
KennyTM
2010-07-02 19:31:59
Excellent! Thanks for the prompt and insightful answer! Just out of curiosity, where do you get information like this? Because I often find that Cocoa documents are not just enough. Do you work for Apple? ;)
Kay
2010-07-03 03:00:38
I wanted to vote this up, but I don't have enough reputation..
Kay
2010-07-03 03:04:42
I've posted a further question in relation to this one. Can you take a look if you have time? Thank you!http://stackoverflow.com/questions/3170723/animation-a-custom-calayer-property
Kay
2010-07-03 07:49:29