CloudKit: Fetch all records with a certain record type?

后端 未结 6 839
鱼传尺愫
鱼传尺愫 2021-02-05 19:50

I have currently got CloudKit set up in my app so that I am adding a new record using the help of the following code below,

CKRecordID *recordID         


        
6条回答
  •  温柔的废话
    2021-02-05 20:12

    Aaaand, I've got it. Using the code below, I was able to create a query to run on the database, to then return an NSArray in the completion block, which I looped through, and returned the value for the saved key in an NSLog.

    NSPredicate *predicate = [NSPredicate predicateWithValue:YES];
    CKQuery *query = [[CKQuery alloc] initWithRecordType:@"Strings" predicate:predicate];
    
    [_privateDatabase performQuery:query inZoneWithID:nil completionHandler:^(NSArray *results, NSError *error) {
        for (CKRecord *record in results) {
            NSLog(@"Contents: %@", [record objectForKey:@"stringArray"]);
        }
    }];
    

提交回复
热议问题