HealthKit的使用
一、项目中关联HealthKit框架
1.在Capabilities选项中打开HealthyKit选项
首先填写好你项目的Bundle Identifier并且选好Team(这两个东西最好事先设置好,以免之后又得重新关联),然后在项目物理文件结构中点选对应的项目,在TARGETS中选择你自身的项目,再在右侧选择Capabilities选项,选择开启HeathyKit选项
图中有4个选项,但是你的可能缺少其中的选项,这个时候可以根据其中缺少的去配置
3.确认你的App ID中HealthyKit选项是可用状态
4.配置plist文件

二、项目中使用HealthKit
1、HealthKit所支持的系统和设备
因为HealthKit框架是在iOS8系统出来之时一同推出的,所以该框架目前只支持iOS8及以上系统,目前支持的设备有iPhone、iWatch,要记得iPad是不支持的哦,如果你的代码同时支持iPhone和iPad设备,那么记得判断下设备还有系统版本号,以免出现不必要的奔溃现象。在项目中导入后,你也可以使用以下代码判断该设备的系统能否使用健康数据:
要想获取健康数据中的步数,则需要通过用户许可才行。具体可以使用以下代码进行授权:
HKHealthStore *healthStore = [[HKHealthStore alloc] init];
NSSet *readObjectTypes = [NSSet setWithObjects:[HKObjectType quantityTypeForIdentifier:HKQuantityTypeIdentifierStepCount], nil];
[healthStore requestAuthorizationToShareTypes:nil readTypes:readObjectTypes completion:^(BOOL success, NSError *error) {
if (success == YES) {
//授权成功
} else {
//授权失败
}
}];
这里调用了requestAuthorizationToShareTypes: readTypes: completion:
方法,用于对应用授权需要获取和分享的健康数据:
1、第一个参数传入一个
NSSet
类型数据,用于告知用户,我的app可能会在你的健康数据库中修改这些选项数据(显然目前我们不需要,传nil)
2、第二个参数也是传入NSSet
类型数据,告知用户,我的app可能会从你的数据库中读取以下几项数据
3、第三个是授权许可回调,BOOL值success
用于区分用户是否允许应用向数据库存取数据
3、获取健康步数
授权完成之后,我们接下来就可以调用API来获取数据库数据了。
HKSampleType *sampleType = [HKSampleType quantityTypeForIdentifier:HKQuantityTypeIdentifierStepCount];
NSPredicate *predicate = [HKQuery predicateForSamplesWithStartDate:nil endDate:nil options:HKQueryOptionStrictStartDate];
NSSortDescriptor *sortDescriptor = [NSSortDescriptor sortDescriptorWithKey:HKSampleSortIdentifierStartDate ascending:YES];
HKSampleQuery *sampleQuery = [[HKSampleQuery alloc] initWithSampleType:sampleType predicate:predicate limit:HKObjectQueryNoLimit sortDescriptors:@[sortDescriptor] resultsHandler:^(HKSampleQuery *query, NSArray *results, NSError *error) {
if(!error & results) {
for(HKQuantitySample *samples in results) {
NSLog(@"%@ 至 %@ : %@", samples.startDate, samples.endDate, samples.quantity);
}
} else {
//error
}
}];
[healthStore executeQuery:sampleQuery];
1、第一段通过传入一个枚举值HKQuantityTypeIdentifierStepCount来创建一个样品类的实例,用于告知,我接下来要获取的数据是步数>2、第二段代码通过创建一个NSPredicate类的实例,用于获取在某个时间段的数据,这里startDate和endDate传入nil,表示获取全部数据,第三个参数传入一个Option,里面有三个值,这个参数我试验了下不同的值代入,发现返回的结果都是一样的,要是有谁知道这个值是做什么用的麻烦告知我一声~
3、第三段代码创建了一个NSSortDescriptor类实例,用于对查询的结果排序
4、第四段代码通过调用HKSampleQuery类的实例方法获取所需数据
5、最后一行代码用于执行数据查询操作
通过这段代码获取的数据,打印出来会发现,它获取的是比较详尽的数据,精确到每一小段时间从开始时间到结束时间内所获取的步数。
4、数据采集
有时候需求并不需要了解这么详尽的数据,只希望获取每小时、每天或者每月的步数,那么我们就需要用到另一个新类HKStatisticsCollectionQuery
进行数据的分段采集
HKQuantityType *quantityType = [HKQuantityType quantityTypeForIdentifier:HKQuantityTypeIdentifierStepCount];
NSDateComponents *dateComponents = [[NSDateComponents alloc] init];
dateComponents.day = ;
HKStatisticsCollectionQuery *collectionQuery = [[HKStatisticsCollectionQuery alloc] initWithQuantityType:quantityType quantitySamplePredicate:nil options: HKStatisticsOptionCumulativeSum | HKStatisticsOptionSeparateBySource anchorDate:[NSDate dateWithTimeIntervalSince1970:] intervalComponents:dateComponents];
collectionQuery.initialResultsHandler = ^(HKStatisticsCollectionQuery *query, HKStatisticsCollection * __nullable result, NSError * __nullable error) {
for (HKStatistics *statistic in result.statistics) {
NSLog(@"n%@ 至 %@", statistic.startDate, statistic.endDate);
for (HKSource *source in statistic.sources) {
if ([source.name isEqualToString:[UIDevice currentDevice].name]) {
NSLog(@"%@ -- %f",source, [[statistic sumQuantityForSource:source] doubleValueForUnit:[HKUnit countUnit]]);
}
}
}
};
[healthStore executeQuery:collectionQuery];
1、第一段代码所做的和之前的一样,定义需要获取的数据为步数
2、第二段代码创建一个NSDateComponents类实例,设置我要获取的步数时间间隔,这里设置为按天统计,这里也可以设置按小时或者按月统计
3、第三段代码创建查询统计对象collectionQuery
,通过传入四个参数进行初始化:
1、第一个参数同上面一样,设置需要查询的类型
2、第二个参数传入一个NSPredicate实例,目前这里传nil
3、第三个参数是关键,传入一个Option可选值,告诉查询统计对象我需要获取的是啥,这里传入HKStatisticsOptionCumulativeSum | HKStatisticsOptionSeparateBySource
值,获取时间段的步数和以及将数据根据不同的数据来源进行分段
4、第四个参数传入一个锚点,类似于数组的索引值,查询将会从改锚点开始查询,这里可以根据不同的锚点值,获取日/周/月/年数据
4、第四段代码是将collectionQuery
对象的block属性initialResultsHandler
进行赋值,该block会在数据查询成功之后进行回调,从中可以获得我们想要的数据
5、最后一行执行该查询统计操作执行这段代码,通过打印的日志可以看到当前设备中存储的按日间隔存储的步行数总和了。
三、HealthKit工具类
EBHealthKitUtils.h
#import <Foundation/Foundation.h>
#import <HealthKit/HealthKit.h> @interface EBHealthKitUtils : NSObject +(id)shareInstance; - (void)getPermissions:(void(^)(BOOL success))Handle; /*!
* @author lei
*
* @brief 获取当天实时步数
*
* @param handler 回调
*/
- (void)getRealTimeStepCountCompletionHandler:(void(^)(double value, NSError *error))handler; /*!
* @author lei
*
* @brief 获取当天所爬楼层
*
* @param handler 回调
*/
- (void)getRealTimeFloorCountCompletionHandler:(void(^)(double value, NSError *error))handler; /*!
* @author lei
*
* @brief 获取一定时间段步数
*
* @param predicate 时间段
* @param handler 回调
*/
- (void)getStepCount:(NSPredicate *)predicate completionHandler:(void(^)(double value, NSError *error))handler; /*!
* @author lei
*
* @brief 获取卡路里
*
* @param predicate 时间段
* @param quantityType 样本类型
* @param handler 回调
*/
- (void)getKilocalorieUnit:(NSPredicate *)predicate quantityType:(HKQuantityType*)quantityType completionHandler:(void(^)(double value, NSError *error))handler; /*!
* @author lei
*
* @brief 获取当天某种类型的运动卡路里
*
* @param predicate 时间段
* @param quantityType 样本类型
* @param handler 回调
*/
- (void)getKilocalorieUnitWithQuantityType:(HKQuantityType*)quantityType completionHandler:(void(^)(double value, NSError *error))handler; /*!
* @author lei
*
* @brief 当天时间段
*
* @return
*/
+ (NSPredicate *)predicateForSamplesToday; /*!
* @author lei
*
* @brief 当天距离
*
* @return
*/
- (void)getDistanceWalkingRunningCompletionHandler:(void(^)(double value, NSError *error))handler; @end
EBHealthKitUtils.m
#import "EBHealthKitUtils.h"
#import <UIKit/UIDevice.h> #import <PPModuleCommonLib/LMBPPConstants.h> #import "ElectronicBalancePch.pch"
#import "ElectronicBalanceApiDefine.h" #import "HKHealthStore+AAPLExtensions.h" @interface EBHealthKitUtils () @property (nonatomic, strong) HKHealthStore *healthStore; @end #define HKVersion [[[UIDevice currentDevice] systemVersion] doubleValue] #define CustomHealthErrorDomain @"com.apple.healthkit" @implementation EBHealthKitUtils +(id)shareInstance
{
static id manager ;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
manager = [[[self class] alloc] init];
});
return manager;
} - (void)getPermissions:(void(^)(BOOL success))Handle
{
if(HKVersion >= 8.0)
{
if ([HKHealthStore isHealthDataAvailable]) { if(self.healthStore == nil)
self.healthStore = [[HKHealthStore alloc] init]; /*
组装需要读写的数据类型
*/
NSSet *writeDataTypes = [self dataTypesToWrite];
NSSet *readDataTypes = [self dataTypesRead]; /*
注册需要读写的数据类型,也可以在“健康”APP中重新修改
*/
[self.healthStore requestAuthorizationToShareTypes:writeDataTypes readTypes:readDataTypes completion:^(BOOL success, NSError *error) {
if (!success) {
NSLog(@"%@\n\n%@",error, [error userInfo]);
return ;
}
else
{
Handle(YES);
}
}];
}
}
} - (NSSet *)dataTypesToWrite
{
return [NSSet set]; } - (NSSet *)dataTypesRead
{
HKQuantityType *activeEnergyType = [HKObjectType quantityTypeForIdentifier:HKQuantityTypeIdentifierActiveEnergyBurned]; // 注释掉暂不使用的内容
/*
HKQuantityType *heightType = [HKObjectType quantityTypeForIdentifier:HKQuantityTypeIdentifierHeight];
HKQuantityType *weightType = [HKObjectType quantityTypeForIdentifier:HKQuantityTypeIdentifierBodyMass];
HKQuantityType *temperatureType = [HKObjectType quantityTypeForIdentifier:HKQuantityTypeIdentifierBodyTemperature];
HKCharacteristicType *birthdayType = [HKObjectType characteristicTypeForIdentifier:HKCharacteristicTypeIdentifierDateOfBirth];
HKCharacteristicType *sexType = [HKObjectType characteristicTypeForIdentifier:HKCharacteristicTypeIdentifierBiologicalSex];
*/ HKQuantityType *stepCountType = [HKObjectType quantityTypeForIdentifier:HKQuantityTypeIdentifierStepCount];
HKQuantityType *floorCountType = [HKObjectType quantityTypeForIdentifier:HKQuantityTypeIdentifierFlightsClimbed];
HKQuantityType *WalkingRunningType = [HKObjectType quantityTypeForIdentifier:HKQuantityTypeIdentifierDistanceWalkingRunning]; // return [NSSet setWithObjects:heightType, temperatureType,birthdayType,sexType,weightType,stepCountType, activeEnergyType,nil]; return [NSSet setWithObjects:stepCountType,floorCountType,activeEnergyType,WalkingRunningType, nil]; } - (void)getDistanceWalkingRunningCompletionHandler:(void(^)(double value, NSError *error))handler
{
if(HKVersion < 8.0)
{
NSDictionary *userInfo = [NSDictionary dictionaryWithObject:@"iOS 系统低于8.0" forKey:NSLocalizedDescriptionKey];
NSError *aError = [NSError errorWithDomain:CustomHealthErrorDomain code:0 userInfo:userInfo];
handler(0,aError);
}
else
{
[self getPermissions:^(BOOL success) {
if(success)
{
HKSampleType *sampleType =
[HKObjectType quantityTypeForIdentifier:HKQuantityTypeIdentifierDistanceWalkingRunning]; HKObserverQuery *query =
[[HKObserverQuery alloc]
initWithSampleType:sampleType
predicate:nil
updateHandler:^(HKObserverQuery *query,
HKObserverQueryCompletionHandler completionHandler,
NSError *error) {
if (error) { // Perform Proper Error Handling Here...
NSLog(@"*** An error occured while setting up the stepCount observer. %@ ***",
error.localizedDescription);
handler(0,error);
// abort();
}
HKQuantityType *stepType = [HKObjectType quantityTypeForIdentifier:HKQuantityTypeIdentifierDistanceWalkingRunning]; [self.healthStore aapl_mostRecentQuantitySampleOfType:stepType
predicate:[EBHealthKitUtils predicateForSamplesToday]
completion:^(NSArray *results, NSError *error) {
if(error)
{
handler(0,error);
}
else
{
double meter = 0;
for(HKQuantitySample *quantitySample in results)
{
HKQuantity *quantity = quantitySample.quantity;
HKUnit *meterUnit = [HKUnit meterUnit];
double value = [quantity doubleValueForUnit:meterUnit];
meter += value;
}
handler(meter, error);
}
}];
}];
[self.healthStore executeQuery:query];
}
}];
}
} - (void)getRealTimeStepCountCompletionHandler:(void(^)(double value, NSError *error))handler
{
if(HKVersion < 8.0)
{
NSDictionary *userInfo = [NSDictionary dictionaryWithObject:@"iOS 系统低于8.0" forKey:NSLocalizedDescriptionKey];
NSError *aError = [NSError errorWithDomain:CustomHealthErrorDomain code:0 userInfo:userInfo];
handler(0,aError);
}
else
{
[self getPermissions:^(BOOL success) {
if(success)
{
HKSampleType *sampleType =
[HKObjectType quantityTypeForIdentifier:HKQuantityTypeIdentifierStepCount]; HKObserverQuery *query =
[[HKObserverQuery alloc]
initWithSampleType:sampleType
predicate:nil
updateHandler:^(HKObserverQuery *query,
HKObserverQueryCompletionHandler completionHandler,
NSError *error) {
if (error) { // Perform Proper Error Handling Here...
NSLog(@"*** An error occured while setting up the stepCount observer. %@ ***",
error.localizedDescription);
handler(0,error);
// abort();
}
[self getStepCount:[EBHealthKitUtils predicateForSamplesToday] completionHandler:^(double value, NSError *error) {
handler(value,error);
}];
}];
[self.healthStore executeQuery:query];
}
}];
}
} - (void)getStepCount:(NSPredicate *)predicate completionHandler:(void(^)(double value, NSError *error))handler
{ if(HKVersion < 8.0)
{
NSDictionary *userInfo = [NSDictionary dictionaryWithObject:@"iOS 系统低于8.0" forKey:NSLocalizedDescriptionKey];
NSError *aError = [NSError errorWithDomain:CustomHealthErrorDomain code:0 userInfo:userInfo];
handler(0,aError);
}
else
{
[self getPermissions:^(BOOL success) {
if(success)
{
HKQuantityType *stepType = [HKObjectType quantityTypeForIdentifier:HKQuantityTypeIdentifierStepCount]; [self.healthStore aapl_mostRecentQuantitySampleOfType:stepType predicate:predicate completion:^(NSArray *results, NSError *error) {
if(error)
{
handler(0,error);
}
else
{
NSInteger totleSteps = 0;
for(HKQuantitySample *quantitySample in results)
{
HKQuantity *quantity = quantitySample.quantity;
HKUnit *heightUnit = [HKUnit countUnit];
double usersHeight = [quantity doubleValueForUnit:heightUnit];
totleSteps += usersHeight;
}
NSLog(@"当天行走步数 = %ld",(long)totleSteps); if(results.count == 0) {
if(results.count == 0){
totleSteps = [[kUserDefaults objectForKey:kEBStepCountsKey]integerValue];
}
} dispatch_async(dispatch_get_main_queue(), ^{
[kUserDefaults setObject:[NSString stringWithFormat:@"%zd",totleSteps] forKey:kEBStepCountsKey];
[kUserDefaults synchronize];
handler(totleSteps,error);
});
}
}]; }
}];
}
} + (NSPredicate *)predicateForSamplesToday {
if(HKVersion >= 8.0)
{
NSCalendar *calendar = [NSCalendar currentCalendar];
NSDate *now = [NSDate date];
NSDateComponents *components = [calendar components:NSCalendarUnitYear|NSCalendarUnitMonth|NSCalendarUnitDay fromDate:now];
[components setHour:0];
[components setMinute:0];
[components setSecond: 0]; NSDate *startDate = [calendar dateFromComponents:components];
NSDate *endDate = [calendar dateByAddingUnit:NSCalendarUnitDay value:1 toDate:startDate options:0];
NSPredicate *predicate = [HKQuery predicateForSamplesWithStartDate:startDate endDate:endDate options:HKQueryOptionNone];
return predicate;
}
else
return nil;
} - (void)getKilocalorieUnit:(NSPredicate *)predicate quantityType:(HKQuantityType*)quantityType completionHandler:(void(^)(double value, NSError *error))handler
{ if(HKVersion < 8.0)
{
NSDictionary *userInfo = [NSDictionary dictionaryWithObject:@"iOS 系统低于8.0" forKey:NSLocalizedDescriptionKey];
NSError *aError = [NSError errorWithDomain:CustomHealthErrorDomain code:0 userInfo:userInfo];
handler(0,aError);
}
else
{
[self getPermissions:^(BOOL success) {
if(success)
{
HKStatisticsQuery *query = [[HKStatisticsQuery alloc] initWithQuantityType:quantityType quantitySamplePredicate:predicate options:HKStatisticsOptionCumulativeSum completionHandler:^(HKStatisticsQuery *query, HKStatistics *result, NSError *error) {
NSLog(@"health = %@",result);
HKQuantity *sum = [result sumQuantity]; double value = [sum doubleValueForUnit:[HKUnit kilocalorieUnit]];
NSLog(@"%@卡路里 ---> %.2lf",sum,value);
if(handler)
{
handler(value,error);
}
}];
[self.healthStore executeQuery:query];
}
}]; }
} - (void)getKilocalorieUnitWithQuantityType:(HKQuantityType*)quantityType completionHandler:(void(^)(double value, NSError *error))handler {
if(HKVersion < 8.0)
{
NSDictionary *userInfo = [NSDictionary dictionaryWithObject:@"iOS 系统低于8.0" forKey:NSLocalizedDescriptionKey];
NSError *aError = [NSError errorWithDomain:CustomHealthErrorDomain code:0 userInfo:userInfo];
handler(0,aError);
}
else
{
[self getPermissions:^(BOOL success) {
if(success)
{
HKStatisticsQuery *query = [[HKStatisticsQuery alloc] initWithQuantityType:quantityType quantitySamplePredicate:[EBHealthKitUtils predicateForSamplesToday] options:HKStatisticsOptionCumulativeSum completionHandler:^(HKStatisticsQuery *query, HKStatistics *result, NSError *error) {
NSLog(@"health = %@",result);
HKQuantity *sum = [result sumQuantity]; double value = [sum doubleValueForUnit:[HKUnit kilocalorieUnit]];
NSLog(@"%@卡路里 ---> %.2lf",sum,value);
if(handler)
{
handler(value,error);
}
}];
[self.healthStore executeQuery:query];
}
}]; }
} - (void)getRealTimeFloorCountCompletionHandler:(void(^)(double value, NSError *error))handler
{
if(HKVersion < 8.0)
{
NSDictionary *userInfo = [NSDictionary dictionaryWithObject:@"iOS 系统低于8.0" forKey:NSLocalizedDescriptionKey];
NSError *aError = [NSError errorWithDomain:CustomHealthErrorDomain code:0 userInfo:userInfo];
handler(0,aError);
}
else
{
[self getPermissions:^(BOOL success) {
if(success)
{
HKSampleType *sampleType =
[HKObjectType quantityTypeForIdentifier:HKQuantityTypeIdentifierFlightsClimbed]; HKObserverQuery *query =
[[HKObserverQuery alloc]
initWithSampleType:sampleType
predicate:nil
updateHandler:^(HKObserverQuery *query,
HKObserverQueryCompletionHandler completionHandler,
NSError *error) {
if (error) { // Perform Proper Error Handling Here...
NSLog(@"*** An error occured while setting up the stepCount observer. %@ ***",
error.localizedDescription);
handler(0,error);
// abort();
}
[self getFloorCount:[EBHealthKitUtils predicateForSamplesToday] completionHandler:^(double value, NSError *error) {
handler(value,error);
}];
}];
[self.healthStore executeQuery:query];
}
}];
}
} - (void)getFloorCount:(NSPredicate *)predicate completionHandler:(void(^)(double value, NSError *error))handler
{ if(HKVersion < 8.0)
{
NSDictionary *userInfo = [NSDictionary dictionaryWithObject:@"iOS 系统低于8.0" forKey:NSLocalizedDescriptionKey];
NSError *aError = [NSError errorWithDomain:CustomHealthErrorDomain code:0 userInfo:userInfo];
handler(0,aError);
}
else
{
[self getPermissions:^(BOOL success) {
if(success)
{
HKQuantityType *stepType = [HKObjectType quantityTypeForIdentifier:HKQuantityTypeIdentifierFlightsClimbed]; [self.healthStore aapl_mostRecentQuantitySampleOfType:stepType predicate:predicate completion:^(NSArray *results, NSError *error) {
if(error)
{
handler(0,error);
}
else
{
NSInteger totleSteps = 0;
for(HKQuantitySample *quantitySample in results)
{
HKQuantity *quantity = quantitySample.quantity;
HKUnit *heightUnit = [HKUnit countUnit];
double usersHeight = [quantity doubleValueForUnit:heightUnit];
totleSteps += usersHeight;
}
NSLog(@"当天所爬的楼层 = %ld",(long)totleSteps); if(results.count == 0){
totleSteps = [[kUserDefaults objectForKey:kEBFloorCountsKey]integerValue];
} dispatch_async(dispatch_get_main_queue(), ^{
[kUserDefaults setObject:[NSString stringWithFormat:@"%zd",totleSteps] forKey:kEBFloorCountsKey];
[kUserDefaults synchronize];
handler(totleSteps,error);
});
}
}]; }
}];
}
} @end
HealthKit的使用的更多相关文章
- HealthKit框架
HealthKit框架相关资料 链接: HealthKit框架参考 HealthKit开发快速入门教程之HealthKit数据的操作 HealthKit开发快速入门教程之HealthKit框架体系创建 ...
- HealthKit开发教程之HealthKit的复合数据
HealthKit开发教程之HealthKit的复合数据 复合数据就是复合单位和值构成的数据.所谓复合单位就是由单位进行乘法.除法等得到的单位,如m/s.lb·ft等就是复合单位.本节将针对这些复合数 ...
- HealthKit开发教程之HealthKit的辅助数据
HealthKit开发教程之HealthKit的辅助数据 在HealthKit中除了主要数据之外,还有6个辅助数据分别为:体积类型数据.压力类型数据.时间类型数据.温度类型数据.标量类型数据和电导率类 ...
- HealthKit开发教程之HealthKit的主要类型数据
HealthKit开发教程之HealthKit的主要类型数据 在HealthKit中,我们将最常用到的数据称之为主要数据.主要数据基本上有三种:长度类型的数据.质量类型的数据.能量类型的数据.本节将主 ...
- HealthKit开发快速入门教程之HealthKit数据的操作
HealthKit开发快速入门教程之HealthKit数据的操作 数据的表示 在HealthKit中,数据是最核心的元素.通过分析数据,人们可以看到相关的健康信息.例如,通过统计步数数据,人们可以知道 ...
- HealthKit开发快速入门教程之HealthKit框架体系创建健康AppID
HealthKit开发快速入门教程之HealthKit框架体系创建健康AppID HealthKit开发准备工作 在开发一款HealthKit应用程序时,首先需要讲解HealthKit中有哪些类,在i ...
- HealthKit开发快速入门教程之HealthKit开发概述简介
HealthKit开发快速入门教程之HealthKit开发概述简介 2014年6月2日召开的年度开发者大会上,苹果发布了一款新的移动应用平台,可以收集和分析用户的健康数据.该移动应用平台被命名为“He ...
- App Store审核指南:WatchKit、HealthKit、ApplePay以及HomeKit部分
将此前App Store审核指南中的WatchKit.HealthKit.ApplePay以及HomeKit部分进行了整理和摘取. 10. 用户界面 10.1 应用程序必须遵守苹果的<Apple ...
- iOS - 苹果健康架构 & 基于HealthKit的健康数据的编辑
最近公司需求,研究了一周之久的苹果健康架构,内容包括:资料调研.报告与HealthKit.framework - API,这一研习还在持续进行中.至此,主要认识到了2点:对苹果健康健康架构设计与实现原 ...
随机推荐
- dependencies 和 devDependencies
npm install node_module –save自动更新dependencies字段值 npm install node_module –save-dev自动更新devDependencie ...
- python 日期相关的各种操作总结
用 Python 做项目时,经常会遇到与日期转换相关,日期计算相关的功能,动不动就要去查python手册,感觉麻烦,因此把自己常用的一些东西,总结了一下,总体说来到目前为止遇到如下一些需求: 1. 用 ...
- C#实现堆栈
堆栈(Stack)是一种特殊的线性表,是一种操作只允许在尾端进行插入或删除等操作的线性表.表尾允许进行插入删除操作,称为栈顶(Top),另一端是固定的,称为栈底(Bottom).栈的操作使按照先进后出 ...
- java、tomcat环境变量的配置(针对windows)
重做了下系统. 于是所有的软件都没了. 好吧,我是故意的,就是把那些我不知道的东西都删掉.. 于是问题来了,java安装好了,tomcat也粘贴完了,环境变量怎么办? 好吧,首先从可爱的java或者说 ...
- git 远程仓库 轻松创建
很多时候,为了方面管理我们写的代码,我们采用git 远程仓库来进行管理和备份.防止代码被他人篡改或删除.那如何来进行创建远程仓库呢? 1.我们必须有一个远程服务器端,在这里可以把任意一台电脑作为服务器 ...
- Git--分布式版本控制系统
使用Git实现多人协作开发 1.简述 每创建一个大的web项目都会有团队协作完成, 然这个过程有可能就像毕业生写论文的过程, 这个过程会有很多...修改的版本, 我们的项目也是会经过无休止的改需求, ...
- javascript 取整,取余数
1.丢弃小数部分,保留整数部分 parseInt(5/2) 2 2.向上取整,有小数,则整数部分加1 Math.ceil(5/2) 3 3.四舍五入 Math.round(5/2) 3 4.向下取整 ...
- javascript-with()方法
1)简要说明 with 语句可以方便地用来引用某个特定对象中已有的属性,但是不能用来给对象添加属性.要给对象创建新的属性,必须明确地引用该对象. 2)语法格式 with(object ...
- MySQL学习(一)
mysql left join,right join,inner join用法分析 left join:是以A表的记录为基础的,A可以看成左表,B可以看成右表,left join是以左表为准的. 换句 ...
- mysql 模糊查询语句比较(LIKE、instr、locate、find_in_set、position)
大家都知道mysql 模糊查询的常用方法是LIKE 但这个语句查询效率很慢,那么有没有比较好的方法呢,下面本人测试了几个语句 测试数据800条左右 1,