Use of IOS Cmpedometer

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.