CALayer valueForKey:
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 righ开发者_如何学运维t 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!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;
精彩评论