i have a basic missunderstanding about how CKQuery works.
I have 2 Record types :
- Friends : containing fields
- url_of_profil_pic
- name
- ...
- Vote : containing fields
- date_of_vote
- target_of_the_vote (Friends CKReference)
- the_one_who_vote (cloudkit user id)
I am just wandering how I could get the url_of_profil_pic when i'm querying on Vote table
Basically, wanted smthing like this :
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"the_one_who_vote = %@", recordReference.recordID];
CKQuery *query = [[CKQuery alloc] initWithRecordType:@"Votes" predicate:predicate];
query.sortDescriptors = [NSArray arrayWithObject:[[NSSortDescriptor alloc]initWithKey:@"createdAt" ascending:false]];
CKQueryOperation *operation = [[[CKQueryOperation alloc] initWithQuery:query] autorelease];
operation.desiredKeys = @[@"target_of_the_vote . url_of_profil_pic"];
operation.resultsLimit = 10;
operation.recordFetchedBlock = ^(CKRecord * _Nonnull record)
where this line will be the predicate that gives me the URL.
operation.desiredKeys = @[@"target_of_the_vote . url_of_profil_pic"];
Assuming you've fetched the record, and that
url_of_profil_pic
is aCKAsset
, you have to convert the asset URL to aData
object that you can save to a file like this:Apple recommends saving anything over 1MB as a
CKAsset
on CloudKit (docs).