CloudKit Not Running As Expected for Storing Documents

27 views Asked by At

My app allows a user to create a PLIST which contains an array of data. I want to have these files accessible on any device, so I have enabled CloudKit in the app, set up the capabilities and profiles and containers for everything, but am running into issues still.

Ok, so in the view where I build the plist and want to save it, I have done:

CKRecord *record = [[CKRecord alloc] initWithRecordType:@"RecordType"];
        record[@"key"] =plist;
        [[CKContainer defaultContainer].publicCloudDatabase saveRecord:record completionHandler:^(CKRecord *record, NSError *error) {
            NSLog(@"Record %@", record);
            NSLog(@"Error %@", error);
        }];

This runs with no error, and the length of bytes it gives me in the NSLog for record looks good.

I then go to the TableView where I want to pull in the array of all the plist files and I have:

NSPredicate *predicate = [NSPredicate predicateWithValue:YES];
    CKQuery *query = [[CKQuery alloc] initWithRecordType:@"RecordType" predicate:predicate];
        
    [[CKContainer defaultContainer].publicCloudDatabase performQuery:query
                                                        inZoneWithID:nil
                                                    completionHandler:^(NSArray *results, NSError *error) {
        NSLog(@"Results %@", results);
    }];

Nothing happens and results comes back as null. Any advice?

0

There are 0 answers