views:

44

answers:

1

Hi

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?

+1  A: 

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.

Mike Weller
Thanks!just confused about that last line 'point.x = t;'Why are you redefining point.x?I'm probably missing something very basic here...
eco_bach
I assumed you wanted to change the value of point.x in-place.
Mike Weller