Search code examples
iosobjective-cicloudcloudkit

Cloudkit different Record Type for every user?


this is a scenario not only me might have thought of a solution... My goal is to sync my App via iCloud but among different users (different iCloud accounts). "Normal" iCloud sync can only sync across different devices using the same iCloud Account. So I thought about if CloudKit could handle this. I read a lot about CloudKit and I am not sure if I understand everything correctly...

So you have a private and a public database. Again, private database is for the same one account only. So I need to go for the public database... But - I don t want everyone to be able to sync the same data, but only "selected friends", other iCloud Accounts...

So is this possible? How would I design that?

My first idea was that user A creates a Record Type with a unique name. Then user B could enter that unique name of that Record Type and by doing this he gets access to the data and user A and user B can sync their apps but other users are excluded. If user C and user D want to use the app together and keep it synced they create their own Record Type.

Would this be the right design? If many users use the app I get many many Record Types...

Or should I just use a unique NSpredicate for every User?

Or how else can I make different users sync their app with specific other users and not with everyone in the public database of the app ??

Thanks for help !


Solution

  • In CloudKit it's not possible to create a new record type in the production database.

    You should solve this by adding a CKReference to your recordTypes which indicates the owner of the record. Then in all your predicates you have to filter on that CKReference.