我无法让我的应用程序获取所有类型的记录并让每个用户记录放入一个数组。
这是保存记录的代码
func locationManager(manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {
let id = CKRecordID(recordName: "01")
let locationRecord = CKRecord(recordType: "location", recordID: id)
locationRecord.setObject(location, forKey: "location")
let publicData = CKContainer.defaultContainer().publicCloudDatabase
publicData.saveRecord(locationRecord) { record, error in
//..
}
}
答案 0 :(得分:5)
您需要使用CKQuery
并将NSPredicate
设置为true:
let predicate = NSPredicate(value: true)
let query = CKQuery(recordType: "location", predicate: predicate)
database?.performQuery(query, inZoneWithID: nil) { results, error in
//...
}
答案 1 :(得分:-1)
CKDatabase *publicDatabase = [[CKContainer defaultContainer]];
NSPredicate *predicate = [NSPredicate predicateWithValue:YES];
CKQuery *query = [[CKQuery alloc] initWithRecordType:@"Group_attributes"];
[publicDatabase performQuery:query inZoneWithID:nil:^(NSArray *results,error){
}];
答案 2 :(得分:-1)
NSPredicate * predicate = [NSPredicate predicateWithValue:YES]; CKQuery * query = [[CKQuery alloc] initWithRecordType:ckEventsRecord谓词:谓词];
[[CloudKitManager publicCloudDatabase] performQuery:query
inZoneWithID:nil
completionHandler:^(NSArray *results, NSError *error) {
NSLog(@"%@",results);
NSLog(@"%@",error);
[arrTemp addObjectsFromArray:results];
}];