-
Notifications
You must be signed in to change notification settings - Fork 443
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Question About Using OCKAny Object #661
Comments
Yep! The If you have just a few new properties that you don't need to query against, there is a lightweight alternative you can consider. Each entity has a var task = OCKTask(...)
task.userInfo["priority"] = "1"
store.addTask(task) |
I see, thank you very much for the full explanation! In that case, wouldn't it be clearer not to have the default Also, is there any documentation on how to create/handle custom stores (other than this bit from the README)? Since there are different store protocols, does that mean I can recreate just the parts I need to customise, or do I have to recreate the entire store? Do I need to set up the whole CoreData stack, too, or it it enough to define the relevant classes? Thank you again! |
Conforming to the type-erased entity protocols allows developers to use any type of store across CareKit. While it does provides flexibility, the downside is that you lose type safety. See this method below as an example of a seam where type safety is lost: We can try and explore some ways to bring type safety back while maintaining the flexibility of using any store. There have been some recent changes to Swift that will be very helpful.
We unfortunately do not have a good example, but feel free to post questions here and I can help you out along the way. If you're interested, you can document the process and modify the Readme!
Great question, it depends. If you're calling CRUD methods on your store, you can absolutely split it up into parts. But if you're using the CareKit view controllers, they require the full fledged |
That makes sense. But since the methods don't work, shouldn't there be a warning (at least; it might make more sense to make it a fatal error), to let people know that a custom Thank you! I will definitely document the entire thing so that it's easier for anyone else interested in this. Is there any other written documentation I can add to, other than the README and carekit-apple.github.io? Or a way to add to the latter? Would love to write an in-depth guide on how to use it, but it might be too long for the README... I'm using a couple of CareKit's view controllers, so as per your comment, I've started building an entire store. I think most of the methods are pretty straightforward, since they seem to be based around regular Core Data objects, but I'm not sure how to handle events and adherence. I thought an event would have its own model, but it doesn't seem to, so how/where are events stored? I know the As far as the Core Data store handling goes, I'm guessing I'll need to create the model for any object that I change, right? So how much of the original Core Data functionality do I need to rebuild for these Any objects? I saw CareKit's models are defined in CareKitStore/CoreData, and the code is generated manually and is based on OCKCDVersionedObject (which is a subclass of OCKCDObject), so do I need to rebuild all that functionality as well? Thank you again for all the help and the detailed answers! |
I've only just noticed the |
We pass back an error to the caller, I would definitely recommend checking that whenever adding tasks to the store. There are a few issues that could pop up.
The Readme is the best spot!
The answer there sort of depends on what your custom models look like. What model requirements have led you to create custom models?
Yep. If you'd like your task to be versioned, you can conform your task to that protocol. As an added benefit, you'll get the |
Hi!
Thank you so much for all the work you do on CareKit and ResearchKit.
I have a question about the Any types (OCKAnyPatient etc). I've been trying to add my own custom type of patient to the store, but I keep getting this error:
CareKitStore.OCKStoreError.addFailed(reason: "Failed to add patients. Not all patients were of the correct type: OCKPatient")
.I've done some digging and it looks like my app fails here. The debugger shows that:
Which I'm guessing means that instead of using the associated Patient type defined in the
OCKReadablePatientStore
, it uses the default OCKStore Patient type. I couldn't find where it's set, but it looks like the OCKStore accepted types definition, hence my guess.The same thing also happens when I try to add a custom plan. I haven't tried the other types, but I doubt it'll go any differently.
Is that supposed to be happening? Am I missing a step in adding a custom type? (e.g., do I have to create a custom store in order to create a custom type?) I've made sure my patient type conforms to
OCKAnyPatient
and I'm using thestore.addAnyPatients
method, which according to the docs seems like it should be enough, but it's entirely possible I missed something.Thank you!
The text was updated successfully, but these errors were encountered: