Search code examples
ioscarekit

Can OCKCarePlanStore queries in Apple's CareKit be run off the main queue?


On GitHub, the documentation for CareKit includes a sample app called "Sample". Within Sample, the file QueryActivityEventsOperation.swift includes a line of code with the following comment:

// <rdar://problem/25528295> [CK] OCKCarePlanStore query methods crash if not called on the main thread

I've been searching, but I can't find this Radar issue documented anywhere. Does anyone know if OCKCarePlanStore query methods are still limited to running in the main queue?


Solution

  • OCKCarePlanStore queries can be run off any queue. As seen on GitHub, the thread is only checked twice: when creating the store and in one of the unit tests.

    This means that the only call restricted to the main thread is initWithPersistenceDirectoryURL:. Any other method can be called on any thread.