我正在尝试使用 CloudKit 查找用户记录 ID。我已验证帐户状态为CKAccountStatusAvailable
。然后我试试这个:
[[CKContainer defaultContainer] fetchUserRecordIDWithCompletionHandler:^(CKRecordID *recordID, NSError *error) {
if (error == nil) {
NSLog(@"Got user record ID (no permission req): %@", recordID);
} else {
NSLog(@"Couldn't get user record ID, error=%@", error);
}
}];
这不可避免地会失败,结果如下:
(lldb) po error
<CKError 0x608000043990: "Not Authenticated" (9/1004); "Account couldn't get container scoped user id, no underlying error received">
(lldb) po [error userInfo]
{
NSDebugDescription = "CKInternalErrorDomain: 1004";
NSLocalizedDescription = "Account couldn't get container scoped user id, no underlying error received";
NSUnderlyingError = "<CKError 0x608000044080: \"Unknown Error\" (1004)>";
}
“未验证”位似乎不正确——我已登录 iCloud 帐户,其他 iCloud 应用程序(例如 TextEdit、Reminders)正常工作(无论如何,如果我没有,我不应该得到CKAccountStatusAvailable
)。我还能/应该在这里做什么?
这是在 OSX,优胜美地 beta 3 上。更新:在 beta 4 中保持不变。