我对 CKQuery 的工作原理有一个基本的误解。
我有 2 种记录类型:
- Friends : 包含字段
- url_of_profile_pic
- 姓名
- ...
- 投票:包含字段
- date_of_vote
- target_of_the_vote(朋友 CK 参考)
- the_one_who_vote(cloudkit 用户 ID)
当我在投票表上查询时,我只是想知道如何获得url_of_profil_pic
基本上,想要这样的东西:
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)
此行将是给我 URL 的谓词。
operation.desiredKeys = @[@"target_of_the_vote . url_of_profil_pic"];