0
首先我知道這個職位:How to identify iCloud logged in user in airplane mode?手機處於飛行模式時如何檢測iCloud用戶?
雖然它似乎沒有答案。一個答案是關於檢測互聯網連接的問題,另一個答案是關於用戶是否改變了。
這裏是我的代碼:
container.accountStatusWithCompletionHandler{
(status: CKAccountStatus, error: NSError?) in
dispatch_async(dispatch_get_main_queue(), {
var title: String!
var message: String!
if error != nil{
title = "Error"
message = "An error occurred = \(error)"
} else {
//title = "No errors occurred getting info"
switch status{
case .Available:
message = "The user is logged in to iCloud"
title = "GOOD"
print("determined status was available")
self.shouldPullFromICloud()
//self.displayAlertWithTitle(title, message: message)
case .CouldNotDetermine:
message = "Could not determine if the user is logged" +
" into iCloud or not"
title = "BAD"
self.noUserIsSignedIn()
case .NoAccount:
message = "User is not logged into iCloud"
title = "BAD"
self.noUserIsSignedIn()
case .Restricted:
message = "Could not access user's iCloud account information"
title = "BAD"
self.noUserIsSignedIn()
}
print(title, message)
}
})
}
似乎很愚蠢的,你需要一個互聯網連接,看是否有用戶登錄到iCloud中。我怎樣才能解決這個問題?
謝謝!
P.S. 如果那篇文章確實包含了我的問題的答案,請您爲我突出顯示它嗎?我找不到它。乾杯!
我用這其他原因,但我仍然需要得到用戶的ID不管的方式,如果他們是在飛行模式或不遐知道嗎? – lelephant