iosicloudcloudkitxcode7ckquery

CKQueryOperation iOS 9 only work plugged in


I am using CloudKit in my iOS 9 app and I have a CKQueryOperation that work fine and performs as expected when plugged into the Mac. As soon as the query is run when it is not plugged in to the Mac, it does not finish. There is no error message, the activity indicator I added never stops and the results are never displayed.

If I start the operation when unplugged, then plug it in it completes too.

The code was copied and adapted from an app built in Xcode 6.4 and works as expected in that app.

Any ideas why this could be happening? Could it be anything to do with app thinning in iOS 9?

Thank you

ANSWER

Adding this fixed the issue: queryOperation.qualityOfService = NSQualityOfService.UserInitiated


Solution

  • The default QoS changed in iOS 9. If the query operation is user initiated, then it needs to be marked as such.

    See CKOperation.h and the QualityOfService property.