An accelerometer related question. (Sorry the formatting may not look right, its the first time I am using this site). I got the accelerometer working as expected using the standard code
UIAccelerometer *accel = [UIAccelerometer sharedAccelerometer];
accel.delegate = self;
accel.updateInterval = 0.1; //I also tried other update values
I use NSLog to log every time the accelerometer:didAccelerate: method in my class is called. The function gets called as expected and everything works fine till here.
However, when I run a loop, the above method doesn't seem to get called. Something like this
float firstAccelValue = globalAccel; //this is the x-accel value (stored in a global by the above method)
float nextAccelValue = firstAccelValue;
while (nextAccelValue == firstAccelValue){
//do something
nextAccelValue = globalAccel; // note globalAccel is updated by the accelerometer method
}
The above loop never exits, expectedly since the accelerometer:didAccelerate: method is not getting called, and hence globalAccel never changes value.
If I use a fixed condition to break the while loop, I can see that after the loop ends, the method calls work fine again.
Am I missing something obvious here? Or does the accelerometer method not fire when certain processing is being done?
Any help would be greatly appreciated! Thanks!