Apple has created a health management application, appropriately called Health, which allows the user to enter their health-related information. This application is backed by a database that programmers don’t have direct access to. However, a layer that is called HealthKit gives us access only to the information that we are authorized to use. Therefore, we need to ask the user for authorization before we can access their information.
There are more than 15 classes that we need to learn about in the
HealthKit framework, and one of the most important is
HKUnit. This class is responsible for representing units in various measures. For instance, one kilogram can be
expressed as grams, milligrams, tons, etc. Also, this class allows you to
convert units with ease. Let’s say that in your country, a person’s weight
is measured in kilograms. But when you go to England, people ask you “How
many stones do you weigh?” because they count weight in stones. The
aforementioned class will help us a lot in working with various units, as
we are going to see in Recipe 3.7.
You want to be able to start using HealthKit in your app.