The sample code (646KB) to accompany the screencast.
The iPhone's accelerometer measures the linear acceleration of the device so can report the roll and pitch, but not the yaw, of the device. However if you are dealing with an iPhone 3GS, which has a digital compass, you can combine the accelerometer and magnetometer readings to have roll, pitch and yaw measurements (see the following section for details of how to access the magnetometer).
The accelerometer reports three figures: X, Y and Z, acceleration values for each axis are reported directly by the hardware as G-force values. Therefore a value of 1.0 represents a load of approximately 1-gravity. While X therefore corresponds to roll, and Y to pitch, the Z value corresponds to whether the device is front-side-up or front-side-down, with a value of 0.0 being reported when the iPhone is edge-on.
This screencast shows how to put together the Accelerometer application which I talked about in the Chapter 10 of the book.
Get the hands-on experience you need to program for the iPhone and iPod Touch. With this easy-to-follow guide, you'll build several sample applications by learning how to use Xcode tools, the Objective-C programming language, and the core frameworks. Before you know it, you'll not only have the skills to develop your own apps, you'll know how to sail through the process of submitting apps to the iTunes App Store.




Help








