Skip to Content
iOS 11 Swift Programming Cookbook
book

iOS 11 Swift Programming Cookbook

by Vandad Nahavandipoor
December 2017
Intermediate to advanced
648 pages
13h 46m
English
O'Reilly Media, Inc.
Content preview from iOS 11 Swift Programming Cookbook

Chapter 17. Core Motion

Apple has finally brought some long-awaited features into the Core Motion framework. It’s especially exciting that the same capabilities, or some version of them, are also available on the Apple Watch. This is great news for us developers because we can program for the watch in a more native way, rather than reading this data from the user’s iPhone and sending it to the watch with Bluetooth.

There are a couple of key terms I’ll be using throughout this chapter that you need to know about:

Cadence

I use a cadence sensor on my bicycle. It helps me figure out how many times I spin my pedals, which can be crucial knowledge. Think about riding downhill on a bicycle, at a 45-degree angle, for 20 minutes out of a total 40-minute bike ride. Without accounting for cadence your total calories burned and effort will be miscalculated because you might not even have pedaled when going downhill. The watch actually includes a cadence sensor for running.

Pace

This is a ratio, dividing the time you have been moving by the distance. If you’re counting in meters, for instance, your pace might be 0.5 seconds per meter, meaning that you travelled 1 meter in half a second.

iOS devices can provide pace and cadence information when it’s available from the pedometer. Some pedometers might not have this information available. You can call the isPaceAvailable() class function of CMPedometer to check whether pace information is available. Similarly, you can call the isCadenceAvailable() ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

iOS 10 Swift Programming Cookbook

iOS 10 Swift Programming Cookbook

Vandad Nahavandipoor
iOS 7 Programming Cookbook

iOS 7 Programming Cookbook

Vandad Nahavandipoor

Publisher Resources

ISBN: 9781491992463Errata Page