I created a record using CloudKit Dashboard, so record is NOT created programmatically. Under "Default Zone, Model Data" (Sorry I need at least 10 reputations to post images.. :/ ) So here's the texted version.
"EventRef0 975f5715-3ccd-4c5f... DeleteSelf Reference"
So I have 3 reference field like this in records that I crated. Now Under "Default Zone, Event." One of those record has the following header.
ID: 975f5715-3ccd-4c5f...
Created:Jan 20 2015 19:00 Created By: _ac6625... Modified: Modified By:
My Question is as following:
1) What do I put in the "Reference" Field of the EventRef0? The Event ID, which I currently have, or something else?
2) Is this is correct way to create multiple References, that is by creating 3 references for 3 Events that I want to reference?
3) When I want to fetch the Events, can I fetch all the CKReferences in one call to an array, and then fetch the Event data indexing that array, or do I have to make separate calls to get each event? I was hoping there is a way to get all the references in an array by keying on the "Reference" attribute. Not sure if that's possible. Preferably is Swift please.
Any help would be greatly appreciated. Thanks.
If you have a 'data' recordType what will have a reference to multiple 'event' recordType objects, then you should add a CKReference in the 'event' recordType where the CKReference points to the 'data' object. So the data object does not need to have a CKReference to the 'event' object. You can get all the event objects by querying the CKReference field for the id of the 'data' object.
Just query your 'events' recordType with a predicate like this: