Reputation: 733
I have an objective-c question. I have an app that detects the rotation of the iOS device. I want to be able to have a timer started when the value is between two ranges. Basically if the rotation is between 0.1 and -0.1 then the timer will trigger.
I have tried while loops, for loops and I'm sure it is something simple I need to implement.
Thanks in advance for the suggestions!
-Brian
Upvotes: 1
Views: 912
Reputation: 22948
Regarding your comment, it looks like you might have the logic reversed.
You had:
if (rotationValue >= 0.1 && rotationValue <= -0.1) {
// doSomethingHere;
}
If you're looking for when the "rotation is between 0.1 and -0.1 then the timer will trigger", then you'd want:
if (rotationValue >= -0.1 && rotationValue <= 0.1) {
// doSomethingHere;
}
(I switched the order around, putting the negative on the left and the positive on the right, as that seems more logical to me, but anyway).
Or you could do:
if (ABS(rotationValue) <= 0.1) {
// doSomethingHere;
}
Upvotes: 2