Search code examples
iosobjective-ccloudkit

discoverAllContactUserInfosWithCompletionHandler faster?


How can I create a CKOperation with higher priority than the default for discoverAllContactUserInfosWithCompletionHandler?

I can't find an example of querying all user info without using [[CKContainer defaultContainer] discoverAllContactUserInfosWithCompletionHandler: which is pretty low priority and takes forever to complete.


Solution

  • The CloudKit documentation for discoverAllContactUserInfosWithCompletionHandler says this:

    This method searches for the users asynchronously and with a low priority. If you want the task to execute with a higher priority, create a CKDiscoverAllContactsOperation object and configure the desired priority.

    You can set the priority like this:

    var operation: CKDiscoverAllContactsOperation = CKDiscoverAllContactsOperation()
    operation.queuePriority = NSOperationQueuePriority.High
    

    Sample code how to use the CKDiscoverAllContactsOperation can be found here: Any working sample code for CKDiscoverAllContactsOperation for IOS8 beta CloudKit?