答案 0 :(得分:1)
首先,获取userId
:
- (void)getUserId
{
[self.defaultContainer fetchUserRecordIDWithCompletionHandler:^(CKRecordID * _Nullable recordID,
NSError * _Nullable error)
{
if (error == nil)
{
self.userRecordID = recordID;
}
}];
}
然后:
CKRecord * record = [[CKRecord alloc] initWithRecordType:@"UserStatus"];
record[@"status"] = @"online";
CKReference *userReference = [[CKReference alloc] initWithRecordID:self.userRecordID action:CKReferenceActionDeleteSelf];
record[@"user"] = userReference;