문제

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?

도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top