对于CKQuery是如何工作的,我有一个基本的了解。
我有两种唱片类型:
当我在表上查询时,我只是想知道如何得到
基本上,想要的东西是这样的:
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"];发布于 2018-11-13 21:55:04
假设您已经获取了记录,并且url_of_profil_pic是一个CKAsset,则必须将资产URL转换为可以保存到以下文件的Data对象:
//record is the CKRecord you fetched
if let asset = record["url_of_profil_pic"] as? CKAsset{
do{
try yourData = Data(contentsOf: asset.fileURL)
//Save yourData to disk...
}catch{
print("Error saving profile pic from CKAsset")
}
}苹果建议将1MB上的任何东西作为CKAsset on CloudKit (文档)保存。
https://stackoverflow.com/questions/53048305
复制相似问题