I'm building an app that needs to sync data between family members (like a shared shopping list), and I'm considering CloudKit. My understanding is that I can either have tables which are public to everyone, or private to only one individual/iCloud account. What I need is a hybrid of both. So two questions:
1) Is there a way to privately share data between Mom and Dad, and only them (a shared private container, in effect)?
2) If I create all the data in a public container and simply filter out who can see what on the app, will that public container data be viewable/hackable to anyone? (I ask this because there may be slightly sensitive data involved). Could someone do the equivalent of "SELECT ALL" and see everything?
Many Thanks,
Josh
There are a couple of ways to achieve something like this. In all cases it comes down to:
Add a CKReference field that will be populated with the ID of the user that you want to share with. Make sure your predicate will filter for that CKReference field where the ID is yours (shared with you) Where and how you store that CKReference depends on how you want to share.
If you only want to share with only one person, then just include that CKReference field into your main recordType. Do not add it to the message as you stated in your question. Add an extra field. If you want to share to a limited number of people, then you could add a field to your recordType which is a list of CKReference. If you want to share with a large group of people, then you could add a group recordType which would have a groupID plus a groupMembers recordType where you would store all user CKReference id's who are member of that group. In all cases the solution would be secure. It all comes down to the predicates that you define in your app. If one of your predicate filters is incorrect, then it could happen that someone sees something that is not for him.
In the demo app of EVCloudKitDao is a chat application based on CloudKit. It is using the convenience library EVCloudKitDao but the structure of sharing something would be similar.