I. INTRODUCTION
Cmpedometer is Apple 8.0 launched, before the only from the framework of the physical engine to do, it is embarrassing. And the 32-bit system is not supported, which means both iphone5 and later models do not support this. Now generally much better, now the company generally minimum to 8.0 or direct 10.0 system, no longer worry about this problem.
Two. Use
First declare an attribute, otherwise he is easy to divulge, Apple's many frameworks are like this, cannot use directly, must pay attention to
@property (Nonatomic,strong) Cmpedometer pedometer;
Three. Judging permissions
Pedometer =[[cmpedometer alloc] init];
Pragma mark returns on the day 00:00
- (nsdate) obtaintodaydate{
return [NSDate Date];
}
Pragma mark returns to the present time
- (nsdate) obtainnexttodaydate{
Nscalendar calendar = [Nscalendar Currentcalendar];
NSDate now = [NSDate Date];
nsdatecomponents components = [Calendar components:nscalendarunityear| nscalendarunitmonth| Nscalendarunitday Fromdate:now];
NSDate startdate = [Calendar datefromcomponents:components];
return startdate;
}
[Pedometer Querypedometerdatafromdate:nil Todate:nil withhandler:^ (cmpedometerdata Nullable pedometerData, NSError Nullable error) {
}]
Four. Note
1. Because I get the time of the day, so the procedure is very simple, get the current time, and then get the next morning time, just a whole day of time
Get the number of steps, this can not be formatted as local time, before formatting has been found dislocation 8 hours.
2. Apple's acquisition of steps, not real-time acquisition per second, easy error, as much as possible 1 minutes to obtain a better, so as to ensure success
3. There are other methods, which are rarely used, and can be clearly understood by looking directly at the gaze.
Use of IOS Cmpedometer