CloudKit CKContainer
处理用户未登录 iCloud 的情况
CKContainer.default().accountStatus { accountStatus, error in
if accountStatus == .noAccount {
DispatchQueue.main.async {
let message =
"""
Sign in to your iCloud account to write records.
On the Home screen, launch Settings, tap Sign in to your
iPhone/iPad, and enter your Apple ID. Turn iCloud Drive on.
"""
let alert = UIAlertController(
title: "Sign in to iCloud",
message: message,
preferredStyle: .alert)
alert.addAction(UIAlertAction(title: "OK", style: .cancel))
self.present(alert, animated: true)
}
}
else {
// Save your record here.
}
}
本文作者:Maeiee
本文链接:CloudKit CKContainer
版权声明:如无特别声明,本文即为原创文章,版权归 Maeiee 所有,未经允许不得转载!
喜欢我文章的朋友请随缘打赏,鼓励我创作更多更好的作品!