如何在CloudKit中设置对当前用户的引用?

时间:2015-10-19 21:53:18

标签: ios cloudkit

我有一个lm(y ~ I(1-exp(-x)) - 1, subset = -seq(5)) ,其中包含我想要设置为应用当前用户的参考字段。 enter image description here

CKRecordType

我该怎么做?

1 个答案:

答案 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;