Getting Accelerometer Data

In HypnosisViewController.m, add the following implementation of the UIAccelerometer delegate method, accelerometer:didAccelerate:. This method will log accelerometer updates to the console. Notice that the types of the two parameters are different even though they look similar:

-​ ​(​v​o​i​d​)​a​c​c​e​l​e​r​o​m​e​t​e​r​:​(​U​I​A​c​c​e​l​e​r​o​m​e​t​e​r​ ​*​)​m​e​t​e​r​
 ​ ​ ​ ​ ​ ​ ​ ​d​i​d​A​c​c​e​l​e​r​a​t​e​:​(​U​I​A​c​c​e​l​e​r​a​t​i​o​n​ ​*​)​a​c​c​e​l​
{​
 ​ ​ ​ ​N​S​L​o​g​(​@​"​%​f​,​ ​%​f​,​ ​%​f​"​,​ ​[​a​c​c​e​l​ ​x​]​,​ ​[​a​c​c​e​l​ ​y​]​,​ ​[​a​c​c​e​l​ ​z​]​)​;​
}​

Build and run the application on your device. Watch the console as you rotate and shake the phone to get a feel for the data that the accelerometer produces.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.139.97.53