Have your class (ViewController, or whatever) implement the UIAccelerometerDelegate protocol. Then
-(void)startListening {
UIAccelerometer *meter = [UIAccelerometer sharedAccelerometer];
meter.updateInterval = 1.0; // One second
meter.delegate = self;
}
Your delegate can then use the UIAcceleration object given it by the UIAccelerometer to do whatever it is you need. For instance, if you only need the magnitude of the iPhone's acceleration, you could, with a double accelMagnitude instance variable, have:
- (void)accelerometer:(UIAccelerometer *)accelerometer didAccelerate:(UIAcceleration *)acceleration {
accelMagnitude = sqrt(acceleration.x * acceleration.x
+ acceleration.y * acceleration.y
+ acceleration.z * acceleration.z);
[self refreshDisplay: accelMagnitude];
}
where refreshDisplay does whatever displaying you need.