【发布时间】:2016-09-19 13:17:17
【问题描述】:
首先我知道这个帖子:How to identify iCloud logged in user in airplane mode?
但它似乎没有答案。一个答案是关于检测互联网连接,另一个是关于用户是否发生了变化。
这是我的代码:
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,这似乎很愚蠢。我该如何解决这个问题?
谢谢!
附: 如果其他帖子确实包含我的问题的答案,请您为我突出显示它吗?我找不到它。干杯!
【问题讨论】: