0

This is my first post here, but have been here many times - I always appreciate the help :) Also, I have Aspergers and am a literal person and sometimes miss things are more apparent to others.

I'm currently learning Swift UI in Xcode 14 and have been using some great resources like iOS Academy, Code with Chris, and WWDC Code Alongs...and have been filling in some of the missing piece with posts from here :) Currently, I am trying to understand how CareKitStore works in relation to CoreData.

For context, I have made some neat beginner apps via tutorials that use both CoreData (making a grocery list from iOS Academy, seen here for reference: https://www.youtube.com/watch?v=rjHBINtpKA8) and have done the WWDC 2022 videos tutorial/code along for CareKit and ResearchKit (3 Video Series, as seen here for reference: https://developer.apple.com/videos/play/wwdc2021/10068/).

As previously mentioned, I somewhat understand the premise that CareKitStore is built on CoreData and what I am having trouble with is understanding how CareKitStore stores the data in comparison to CoreData, like if I were to store data in a CoreData set through CareKit. For example, I am watching a different video, the WWDC 2020 video ("What's new in CareKit" seen here: https://developer.apple.com/videos/play/wwdc2020/10151/) and looking at this code:

`import CareKit

import CareKitStore

let coreDataStore = OCKStore(name: "core-data-store") let healthKitPassthroughStore=OCKHealthKitPassthroughStore(name: "hk-passthrough-store")

let coordinator = OCKStoreCoordinator() coordinator.attach(store: coreDataStore) coordinator.attach(eventStore: healthKitPassthroughStore)`

...does this correlate to a literal CoreData Entity named "core-data-store" the same way that the following code from the iOS Academy video does for "ToDoListItem":

let items = try context. fetch (ToDoListItem,fetchRequest())

In the WWDC 2020 video they don't show the setup of a CoreData base, Entities, etc. so I wasn't sure if it was just understood that Core Data was already set up and CareKitStore is storing them literally into a CoreData set (as seen in the iOS Academy example) or if it is doing something different, if so, what?!

If any of you can help provide any insight, could point me in the right direction here, or know of any tutorials I would be much appreciative!

Thank you!

Fitz
  • 21
  • 3
  • No, "core-data-store" is the name of the persistence store used by CareKit. I don’t know anything about this framework but I assume it internally uses Core Data for its storage and working with it is quite different from working directly with Core Data so you can’t really compare the two. – Joakim Danielson Nov 16 '22 at 06:58
  • I had a quick glance at the documentation and I clearly got the impression that you don’t need to know Core Data to use Care Kit so ignore Core Data and focus on CareKit if this is what you want to learn about. – Joakim Danielson Nov 16 '22 at 07:06
  • Hi Joakim, thank you for the responses! That's interesting, if I'm understanding you correctly then, the CareKit framework seems advanced in that it takes out the need for the user to directly interact with CoreData. – Fitz Nov 16 '22 at 15:32
  • Question for understanding: Would you happen to know if a framework internally uses CoreData, like CareKit does here, is the framework still conceptually using CoreData in the same way that I would if I were to need to configure and interact with it myself - just in a more automated way? Thank you again! :) – Fitz Nov 16 '22 at 15:33
  • I am pretty sure Apple developers using Core Data in their work uses the same public API we do. – Joakim Danielson Nov 16 '22 at 17:37

0 Answers0