tags:

views:

124

answers:

2

I am asking for an Value like this:

[self.layer valueForKeyPath:@"transform.rotation.z"]

bit I need to pass it to a method which takes a CGFloat as parameter. What's the casting trick here?

+5  A: 

Try

NSNumber* n = [self.layer valueForKeyPath:@"transform.rotation.z"];
CGFloat f = [n floatValue];
Rhythmic Fistman
A: 

If you wanted a more concise, one line way to do that, you can do:

CGFloat f = [[self.layer valueForKeyPath:@"transform.rotation.z"] floatValue];
Neil Daniels