Apple Health Frameworks

Nov 29 2022 Swift 5, iOS 15, Xcode 13

Part 2: Dive Into More Details

9. Work With StoreManager

Episode complete

Play next episode

Save for later
About this episode
See forum comments
Cinema mode Mark complete Download course materials
Previous episode: 8. Create a CheckIn Task Next episode: 10. Make a Follow-Up Vaccination Task

This video Work With StoreManager was last updated on Nov 29 2022

Heads up... You've reached locked video content where the transcript will be shown as obfuscated text.

You can unlock the rest of this video course, and our entire catalogue of books and videos, with a Professional subscription.

Part 2, Episode 10, Work with StoreManager

In this episode, I want to show you how to work with CareKitStore using StoreManager. Until now, you had the StoreManager on the memory, which means every time you opened the app, it was empty, but from now on, I want to tell you how to store it on the disk, so you don’t need it to do the onboarding task again and again.

      type: .onDisk(protection: .none)
static func fetchTasks(on date: Date, storeManager: OCKSynchronizedStoreManager, completion: @escaping([OCKAnyTask]) -> Void) {
    var query = OCKTaskQuery(for: date)
    query.excludesTasksWithNoEvents = true
      query: query,
      callbackQueue: .main) { result in
      switch result {
      case .failure:
        Logger.task.error("Failed to fetch tasks for date \(date)")
      case let .success(tasks):
TaskViewModel.fetchTasks(on: date, storeManager: self.storeManager) { tasks in
            tasks.forEach {
              guard let id = TaskModel(rawValue: $ else { return }
              if id == TaskModel.checkIn {
                  input: id,
                  date: date,
                  storeManager: self.storeManager,
                  listViewController: listViewController,
                  delegate: self)