Giter VIP home page Giter VIP logo

healthkit-master's Introduction

在苹果官方HealthKit 的Demo基础上添加修改运动步数的功能

Fit: HealthKit in Action

===========================================================================

Fit is a sample intended as a quick introduction to HealthKit. It teaches you everything from writing data into HealthKit to reading data from HealthKit. This information may have been entered into the store by some other app; e.g. a user's birthday may have been entered into Health, and a user's weight by some popular weight tracker app. However, some of this information may not yet be populated (or you may not have access to it) and you should consider how to present this scenario to your users.

Fit shows examples of using queries to retrieve information from HealthKit using sample queries and statistics queries. Fit gives you a quick introduction into using the new Foundation classes NSLengthFormatter, NSMassFormatter, and NSEnergyFormatter.

Note: For important guidelines that govern how you can use HealthKit and user health information in your app, see https://developer.apple.com/app-store/review/guidelines/#healthkit.

=========================================================================== Using the Sample

Fit tries to emulate a fitness tracker app. The goal of this fitness app is to track the net energy burn for a given day. Net energy is defined in this app as:

Total Energy Consumed - Total Active Energy Burned - Total Resting Energy Burned.

This resting or basal energy burn is calculated as a function of your height, weight, age, sex and the time of the day.

AAPLProfileViewController shows how to retrieve a user's age, height, and weight information from HealthKit. This is an example of retrieving a characteristic data type. Height and weight are quantity types, and you will learn how to retrieve these quantities from an HKHealthStore object using a sample query. You’ll also notice code to save valid user entered height and weight information into a HKHealthStore object. Note that in order to see a valid height or weight calculation in the profile view controller, you'll want to make sure you have height or weight data saved. You can either do this from within the Fit app or you can store this data in another app (such as Health in the "Health Data" tab).

AAPLJournalViewController tracks the user’s food consumption details for the day. You will find code that lets a user save into and retrieve food items from HealthKit, where each item is stored as an HKCorrelation instance. Saving each food item as an HKCorrelation lets us correlate the various pieces of information associated with that entry. For instance, in our sample code, we save the food item's name, calories, fat and carb information, all correlated to each other. You will also see how the journal is updated using a sample query to retrieve all the HKCorrelation instances from HealthKit.

AAPLEnergyViewController shows an example of using the statistics query. This sample uses a statistics query to retrieve the cumulative sum of calories of all the food samples entered using the AAPLJournalViewController.

=========================================================================== Build/Runtime Requirements

This sample requires capabilities that are only available when run on an iOS device. Note that in order to run this sample on a device, you will need to change the bundle identifier of the application.

Building this sample requires Xcode 6.0 and iOS 8.0 SDK Running the sample requires iOS 8.0 or later.

=========================================================================== Copyright (C) 2008-2014 Apple Inc. All rights reserved.

healthkit-master's People

Contributors

helloyeah avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.