From the course: Advanced iOS App Development: Core Motion

Core Motion - iOS Tutorial

From the course: Advanced iOS App Development: Core Motion

Start my 1-month free trial

Core Motion

- [Instructor] If your phone moves, and detects it, that is Core Motion in action. Core Motion is the framework for detecting any kind of movement of your iOS device. From the lifting of your wrist to show the Apple Watch face, to locking your pace in a running or cycling App, Core Motion turns motion into data. Core Motion works by a series of motion sensors in your device. Devices have a variety of sensors, or processing power for detecting motion. Depending on the device, there are one of several sensors that tell the iPad or iPhone about position and motion on the device. One habit you'll get into early is to check if a sensor exists on a device. One sensor almost every device has is the Accelerometer. The Accelerometer measures acceleration of the phone in three dimensions. Another device we'll discuss is the Gyroscope, which gives a rotation-rate in three dimensions. On some devices, there's also an Altimeter. Which can detect changes in air pressure, and convert that into changes in altitude. On almost every device, there's a Magnetometer. Which Core Location also uses for a compass. With sensor data, you as a developer will need to do two things. Determine if the data is Noise or Signal, and interpret that data into an action. You might have an app that turns on the display when you pick it up from the table. We'll cover more about this as we go through the course. In some cases, such as deciding when a user is running, walking, or riding a bike, Core Motion will do the tough work for you. Before we dive into code for Core Motion, you'll need to be familiar with some concepts about measuring movement, and how iOS organizes Core Motion devices. In the rest of this chapter, I'll introduce those topics for you. Some might be familiar, some might be new, but all will be useful.

Contents