這是Objective-C的版本:
CKContainer *container = [CKContainer defaultContainer];
[container accountStatusWithCompletionHandler:^(CKAccountStatus accountStatus, NSError *error)
{
if (((accountStatus == 3) || (accountStatus == 2)) && (!error))
{
NSLog(@" no error but status %ld",accountStatus);
// typedef NS_ENUM(NSInteger, CKAccountStatus) {
// /* An error occurred when getting the account status, consult the corresponding NSError */
// CKAccountStatusCouldNotDetermine = 0,
// /* The iCloud account credentials are available for this application */
// CKAccountStatusAvailable = 1,
// /* Parental Controls/Device Management has denied access to iCloud account credentials */
// CKAccountStatusRestricted = 2,
// /* No iCloud account is logged in on this device */
// CKAccountStatusNoAccount = 3,
//
// }
}
if (error)
{
NSLog(@" accountStatus error %@",error);
}
} ];
的[保存CloudKit記錄「未通過身份驗證」可能的複製(1002分之9 )「」此請求需要經過身份驗證的帳戶「」](http://stackoverflow.com/questions/26253415/saving-cloudkit-record-not-authenticated-9-1002-this-request-requires-an-a) – brainray 2016-12-04 23:06:18
[看到這個asnwer](http://stackoverflow.com/questions/27315155/cloudkit-cksubscription-error-this-request-requires-an-authenticated-account/42473794#42473794),有時它可能是愚蠢的錯誤。 – 2017-02-26 20:25:19