'During Cloudkit query neither recordFetchedBlock or recordMatchedBlock getting called but queryCompletionBlock runs without error
I have an app that queries a Cloudkit public database.
This worked perfectly in previous versions, but after an update to ios15 it started behaving oddly and I realised that the recordFetchedBlock is not being called at all.
I saw the depreciation and tried to replace it with recordMarchedBlock but this also does not seem to call.
Anyone know what I am doing wrong?
In console I get "query successful" but no "Check if this works ...." whether I keep both blocks in, use them separately or wrap them in a version check..
Test code below
Meet* meetObject = self.meetObject;
CKDatabase *publicDatabase = [[CKContainer defaultContainer] publicCloudDatabase];
NSPredicate *predicatemeet = [NSPredicate predicateWithFormat:@"onlineID = %@", meetObject.onlineID];
NSLog(@"meetobject %@", meetObject.onlineID);
NSPredicate *predicateowner = [NSPredicate predicateWithFormat:@"updateByUser = %@", @"owner"];
NSArray *preds1 = [NSArray arrayWithObjects: predicatemeet,predicateowner, nil];
NSPredicate *predicateM = [NSCompoundPredicate andPredicateWithSubpredicates:preds1];
CKQuery *queryMeet = [[CKQuery alloc] initWithRecordType:@"Meet" predicate:predicateM];
CKQueryOperation *queryOpMeet = [[CKQueryOperation alloc] initWithQuery:queryMeet];
queryOpMeet.database = publicDatabase;
queryOpMeet.qualityOfService = NSQualityOfServiceUserInitiated;
NSLog(@"here1");
//// test code
///
queryOpMeet.recordMatchedBlock= ^(CKRecordID *recordID, CKRecord *meet, NSError *error) {
NSLog(@"Check if this works recordMatchedBlock");
};
queryOpMeet.recordFetchedBlock = ^(CKRecord *meet)
{
NSLog(@"Check if this works recordFetchedBlock");
};
queryOpMeet.queryCompletionBlock = ^(CKQueryCursor *cursor, NSError *error)
{
if (error) {
NSLog(@"CKQuery Error %@", error);
}
else
{
NSLog(@"query successful");
}
};
//self.queue = [[NSOperationQueue alloc] init]; called in viewdidload
[self.queue addOperation:queryOpMeet];
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
