Objective-C Using Accelerometer (iPhone)

Posted by Johannes Jensen on Stack Overflow See other posts from Stack Overflow or by Johannes Jensen
Published on 2010-04-16T09:56:13Z Indexed on 2010/04/16 10:13 UTC
Read the original article Hit count: 289

Filed under:
|
|

I have a class called MainGame, which is defined like this in my .h:

@interface MainGame : Renderer <UIAccelerometerDelegate>

Then later in my .m I have this:

- (void) accelerometer: (UIAccelerometer *)accelerometer didAccelerate: (UIAcceleration *)acceleration {
    // here I would read values like accelerometer.x
    NSLog(@"accelerated!!1");
}

Am I doing it right?

Currently I'm only testing in iPhone simulator, I'm going to buy the apple $99 developer thing soon. It doesn't log "accelerated!!1", but I'm guessing that's because I'm not running it on an actual device yet?

© Stack Overflow or respective owner

Related posts about iphone

Related posts about objective-c