2

Recently I face a problem which is rare to appear What I try to do is to get the number of steps per minute.

In my code:

let date = NSDate()
    for i in 0...1000 {
        dispatch_async(mySerialQueue) {
            self.pedoMeter.queryPedometerDataFromDate(date.dateByAddingTimeInterval( Double(i+1) * -60.0 ), toDate: date.dateByAddingTimeInterval( Double(i) * -60.0 ), withHandler: { (data, error) in
                if let data = data {
                    print("\(data.numberOfSteps)")
                }
            })
        }
    }

Sometimes, the number of steps would return a big number which can be >1000000. After tracing the device log, I found that there is a error log:

Sep 15 16:42:59 locationd[6315] <Error>: Steps were found to be non monotonically increasing - start:488825.000000, end:488825.000000

and that is the weird step number.

I am trying to avoid the problem. That's why I am using a serial queue to do the query. However, I failed. Is there any way to avoid it?

Horst
  • 1,733
  • 15
  • 20

0 Answers0