ios icloud 在设备中以编程方式设置 on/off

ios icloud set on/off programatically in the device

我是 iOS 和 ICloud 的新手。我有一个与 iCloud 同步核心数据的应用程序,我想知道如何检查设备是否禁用了 iCloud 或 iCloud Drive 设置,在这种情况下,请用户从应用程序中以编程方式启用它。

示例:

提前致谢。

accountStatusWithCompletionHandler可用于检测当前用户的iCloud账户是否可以访问

This method determines the status of the current user’s iCloud account asynchronously, reporting the results to the block in the completionHandler parameter.

它在 ios 8 及更高版本中可用。

请检查here这已经回答