Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does CMErrorDomain error 103. mean? (CMPedometer)

I'm struggling totally to get CMPedometer to return any step data. However Iconfigure I get Error Domain=CMErrorDomain Code=103 "The operation couldn’t be completed. (CMErrorDomain error 103.)"

I'm using swift and have broken down the queryPedometerDataFromDate query to be as simple as possible.

    let pedometer = CMPedometer()
    let fromDateString = "2015-01-22"
    let toDateString = "2015-01-23"
    let dateFormatter = NSDateFormatter()
    dateFormatter.dateFormat = "YYYY-MM-DD"
    let fromDate = dateFormatter.dateFromString(fromDateString)
    let toDate = dateFormatter.dateFromString(toDateString)

    pedometer.queryPedometerDataFromDate(fromDate, toDate: toDate) { (data:CMPedometerData!, error:NSError!) -> Void in

        if error == nil {
            println(data)
        } else {
            println(error)
        }
    }

I've enabled motion detection for my app, and have no problem getting similar data out of HealthKit.

I must be missing something simple, but I can't see what it is!

like image 935
Ben Walton Avatar asked Jan 26 '15 05:01

Ben Walton


1 Answers

Ok, so after another day of research. You have to have the CMPedometer object as a global variable for your class. If it's defined as a local variable like in the question it won't work. Simply adding let pedometer = CDPedometer() at the class level will fix this issue.

like image 127
Ben Walton Avatar answered Nov 09 '22 10:11

Ben Walton