views:

64

answers:

3

Hey I have a problem comparing the value of a CGPoint (struct with two ints: x and y) with another at certain time intervals.

One is called location and has the value of where the cursor is. Every half a second or so, I want to see if it changed. How do I do this? The language is Objective-C (so C++/C stuff should work)

A: 

As noted in the CGGeometry docs, Apple provides a function, CGPointEqualToPoint(), for doing just this. You would have a CGPoint variable that stores the old value and compare it to the new value you get.

Chuck
Yes, but I'm wondering how to temporarily store the value of a CGPoint and compare it later.
A: 

Take a look at the NSTimer documentation. It does what you want.

Cinder6
I'm using that. The problem is storing the value of the touch location and not updating it.
+1  A: 

What are you trying to do with this? Would it make more sense to use Key Value Observing to observe when one or both values change?

Martin Gordon
I'm trying to check when the user keeps his finger at the same spot, and only increment a variable ticks when the finger has moved.
The four touches*:withEvent: methods of UIResponder should help you, particularly touchesMoved:withEvent:
Martin Gordon
Wow...I was even using those functions. Just had to put ticks += 10 in the touchesMoved:withEvent one. I feel stupid...