通过 iCloud 备份恢复设备时,应用程序数据未恢复

App data is not restored when device is restored via iCloud Backup

用户报告说,当他们从 iCloud(而不是 iTunes)备份恢复设备时,我的应用程序的数据没有恢复。我不清楚我需要采取哪些步骤来确保在从 iCloud 备份恢复整个设备时恢复我的应用程序数据。

我没有在应用程序功能中启用 iCloud;这是我需要采取的步骤之一来确保我的数据包含在恢复中吗?我需要采取的其他步骤和需要检查的事项是什么?

更多信息: 我有一个 Core Data 应用程序并存储一个 .sqlite 文件。我将文件存储在 [[UIApplication sharedDelegate] applicationDocumentsDirectory] ​​中。我使用 NSUserDefaults。我的应用程序没有出现在“设置”中的任何 iCloud 列表中。

您不必包含 iCloud 功能。 iCloud 会自动备份保存到 DocumentsDirectory 的内容,还会保存 NSUserDefaults.

请记住,对于那些您不希望包含在 iCloud 中的数据,您必须添加 - (BOOL)addSkipBackupAttributeToItemAtPath:(NSString *) filePathString 标志。 Apple 对此备份非常严格,您必须仅保存 用户生成的内容,否则应用将被拒绝。

Important: Apps should avoid mingling app data and user data in the same file. Doing so will unnecessarily increase backup sizes and can be considered a violation of the iOS Data Storage Guidelines.

要查看您的应用程序在 iCloud 备份中使用了多少 space(并确定您的数据是否已保存),您可以在此处查看:

- Install and launch your app
- Go to Settings > iCloud > Storage > Manage Storage
- Select your device
- If necessary, tap "Show all apps"
- Check your app's storage

如果您知道您的应用应该存储更大的数据,您会在那里看到,但请注意,100-150kb 以下的数据来自 NSUserDefaults

如果您有更多问题,请告诉我。