Converting 'x' value of a CGPoint ivar to NSTimeInterval?
-
26-09-2019 - |
Question
I have a velocity ivar defined as a CGPoint.
I need to somehow extract just the 'x' value of velocity, and then use this to call-send a message to the following method signature
-(void) adjustTimer:(NSTimeInterval*)newInterval
How do I obtain just the 'x' value of a CGPoint? Do I then need to convert or cast this result before calling my adjustTimer method?
Solution
This should do it:
NSTimeInterval t = (NSTimeInterval) point.x;
[self adjustTimer:&t];
point.x = t;
Note that NSTimeInterval
is a double and x is a CGFloat, so it's not safe to pass a direct pointer to your x value.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow