0

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?

rmaddy
  • 314,917
  • 42
  • 532
  • 579
Bill Nattaner
  • 774
  • 7
  • 15

1 Answers1

0

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.

tktsubota
  • 9,371
  • 3
  • 32
  • 40
  • Thanks! I will see if I can raise the outdated comment as an issue on GitHub. Apparently the Sample code is out of date. Instances of QueryActivityEventsOperation accepts a time range and a activityIdentifier as input. When run the operation (1) retrieves the activity and then (2) retrieves all events for that activity in the time range. Both tasks (1) and (2) are forced to run on the main queue, which does not seem right. – Bill Nattaner Jan 03 '17 at 17:03
  • @BillNattaner It is definitely out of date—I've personally tested it on a different sample project that I made, which fetched two activities' events at the same time. Only one of them were on the main thread but it still worked fine, no error messages or anything. I'll check out your issue on GitHub. – tktsubota Jan 03 '17 at 19:00