Thanks for being a part of WWDC25!

How did we do? We’d love to know your thoughts on this year’s conference. Take the survey here

How to properly share one CKREcord with CKShare in obj-c

When I trying to set share record I get: NSOperationQueue * quwuw = [[NSOperationQueue alloc] init]; [quwuw setMaxConcurrentOperationCount:1];

[self createOrFetchZone:^(CKRecordZone *rzone, NSError *error) {
CKRecordID *recordID = [[CKRecordID alloc] initWithRecordName:recordId zoneID:custZone.zoneID];
[[self privateCloudDatabase] fetchRecordWithID:recordID completionHandler:^(CKRecord *record, NSError *error) {
    
    
    if (error) {
        dispatch_async(dispatch_get_main_queue(), ^{
            prephandler(nil, nil,error);
        });
        return;
    }
    
    CKShare * share = [[CKShare alloc] initWithRootRecord:record];
        
        share[CKShareTitleKey] = @"Some title";
        [share setPublicPermission:CKShareParticipantPermissionReadWrite];
        CKModifyRecordsOperation * op = [[CKModifyRecordsOperation alloc] initWithRecordsToSave:@[share, record] recordIDsToDelete:nil];
        [op setModifyRecordsCompletionBlock:^(NSArray<CKRecord *> * _Nullable savedRecords, NSArray<CKRecordID *> * _Nullable deletedRecordIDs, NSError * _Nullable operationError) {
            if (operationError == nil) {
                dispatch_async(dispatch_get_main_queue(), ^{
                    prephandler(share, [CKContainer defaultContainer],operationError);
                });
                
            }
            else {
                dispatch_async(dispatch_get_main_queue(), ^{
                    prephandler(share, [CKContainer defaultContainer],operationError);
                });
            }
        }];
        [op  setDatabase:[self privateCloudDatabase]];
    [quwuw addOperation:op];
}];
}];

I get error: Invalid Arguments" (12/2006); server message = "Chaining supported for hierarchical sharing only"

Any advices for this?

How to properly share one CKREcord with CKShare in obj-c
 
 
Q