I have a record type that has two fields...both fields are just CKReferences to two other record types. It's worked fine so far but I just came across a need to get the original records from the CKReference record. Since I've already retrieved the record containing the references and stored it in a dictionary, I was trying to get the original record from within the reference object via the key. However, I wasn't getting the data I was expecting so I NSLogged the class type saw it coming out as a CKReference instead of the original class (record) type. I'm trying to avoid making another database (cloudkit) call to get the records I need. The keys in the dictionary are the record ids of the original records from the CKReference records, so I already have the correct record ids.
So, is this even possible, or will I be forced to just take the record ids and make a CKFetchRecordsOperation call?
Here's my code for processing the record that contains the two CKReference records...
UserActivity *userActivity = [[UserActivity alloc] init];
CKReference *cidReference = [[CKReference alloc] initWithRecord:record[IMAGE_DATA_RECORD_TYPE] action:CKReferenceActionNone];
//NSLog(@"RecordID of cidReference: %@", cidReference.recordID.recordName);
ImageData *imageData = (ImageData *)cidReference;
It's the imageData object that does not contain the expected data, which is because it's not the right class...it's a CKReference class.
Thanks in advance!
Aucun commentaire:
Enregistrer un commentaire