从iOS 6到iOS 7的转换,我很难找到对我的问题的正确或任何好的参考。
我们的iOS 6应用程序版本:当iCloud被禁用/不可用时,使用iCloud和本地回退存储。已使用此iOS 6版本,并且iCloud存储文件中填充了大量数据。
我们的iOS 7应用程序版本:配置了新的iOS 7 iCloud Core Data API。首次运行此版本不会显示使用iOS 6版本捕获的现有iCloud存储数据,即使该文件存在且包含所有数据。原因是正在使用新的闪亮Core Data回退存储,并且不包含任何现有数据。只有在很长一段时间后才会出现数据。这并不理想,因为它看起来好像用户丢失了数据。
是否存在此问题的现有解决方案,还是应该通过在新的备用存储为空并填充时使用不同的备用存储来手动处理?
正如脚注一样,模型也有一些轻量级变化。不确定这个空数据库是否也是迁移的产物?将做一个测试,看看我是否可以建立这个。
答案 0 :(得分:0)
最初由iOS7下的Core Data提供的后备存储将不会填充来自iCloud的任何数据。但是,如果用户在iCloud存储准备就绪之前输入了一些数据,则该数据将在可用时迁移到iCloud存储。
如果您的应用正在执行轻量级迁移,那么这很可能是您看到延迟的原因。一旦迁移完成并重新启动应用程序,那么启动时间应该会非常小。
测试延迟是否来自迁移的另一种方法是使用旧模型,因此不需要迁移,并查看这是否会产生实质性差异。
请注意,除非您的用户输入数据,否则不会填充新的备用商店。
如果您观察到NSPersistentStoreCoordinatorStoresDidChangeNotification
和NSPersistentStoreCoordinatorStoresWillChangeNotification
,则会在商店切换时通知您。
您可能还希望在升级过程中向用户显示消息,即直到您收到NSPersistentStoreCoordinatorStoresDidChangeNotification
通知为止。
查看WWDC2013 207会话说明和视频。
编辑: 这是iCloud文件打开的日志。这一行
2013-12-11 10:47:10.794 iProject2iOS[5431:60b] AppDelegate.fileOpened called
从UIManagedDocument打开完成处理程序调用。这样就告诉我UIManagedDocument已成功打开。此时我知道它正在使用本地后备商店。 之后,我必须等待一段时间,然后出现下一行
2013-12-11 10:47:11.291 iProject2iOS[5431:60b] AppDelegate.storesDidChange called - >>>>>>>>>>>>>>>>>>>>>>>>>>>>
这是处理storesDidChange通知,现在我知道应用程序正在使用iCloud存储。但是,如果设备尚未下载并导入任何日志,则根据设备的不同,iCloud存储可能仍为空。为了解决这个问题,我有一个检查,看看我是否能在数据库中找到特定的记录,一旦找到它们,我知道数据导入至少已经进展到加载种子数据。我还应该提一下,我在创建本地副本之前检查是否存在iCloud文件以避免合并问题。显然,如果iCloud关闭,那么这是不可能的。
2013-12-11 10:47:10.290 iProject2iOS[5431:60b] AppDelegate.loadFile called.
2013-12-11 10:47:10.292 iProject2iOS[5431:60b] AppDelegate.managedObjectModel called.
2013-12-11 10:47:10.509 iProject2iOS[5431:60b] AppDelegate. setting merge policy
2013-12-11 10:47:10.545 iProject2iOS[5431:60b] AppDelegate.storesDidChange called - >>>>>>>>>>>>>>>>>>>>>>>>>>>>
2013-12-11 10:47:10.555 iProject2iOS[5431:5877] CoreData: warning: no NSValueTransformer with class name 'NSKeyedUnarchiveFromDataTransformerName' was found for attribute 'preferences' on entity 'Details'
2013-12-11 10:47:10.556 iProject2iOS[5431:5877] CoreData: warning: no NSValueTransformer with class name 'NSKeyedUnarchiveFromDataTransformerName' was found for attribute 'scope' on entity 'Details'
2013-12-11 10:47:10.558 iProject2iOS[5431:5877] CoreData: warning: no NSValueTransformer with class name 'NSKeyedUnarchiveFromDataTransformerName' was found for attribute 'details' on entity 'ExpenseTransaction'
2013-12-11 10:47:10.560 iProject2iOS[5431:5877] CoreData: warning: no NSValueTransformer with class name 'NSKeyedUnarchiveFromDataTransformerName' was found for attribute 'details' on entity 'Interface'
2013-12-11 10:47:10.562 iProject2iOS[5431:5877] CoreData: warning: no NSValueTransformer with class name 'NSKeyedUnarchiveFromDataTransformerName' was found for attribute 'details' on entity 'Issues'
2013-12-11 10:47:10.564 iProject2iOS[5431:5877] CoreData: warning: no NSValueTransformer with class name 'NSKeyedUnarchiveFromDataTransformerName' was found for attribute 'details' on entity 'OpexTransaction'
2013-12-11 10:47:10.568 iProject2iOS[5431:5877] CoreData: warning: no NSValueTransformer with class name 'NSKeyedUnarchiveFromDataTransformerName' was found for attribute 'details' on entity 'ProjectNode'
2013-12-11 10:47:10.570 iProject2iOS[5431:5877] CoreData: warning: no NSValueTransformer with class name 'NSKeyedUnarchiveFromDataTransformerName' was found for attribute 'details' on entity 'Risks'
2013-12-11 10:47:10.573 iProject2iOS[5431:5877] CoreData: warning: no NSValueTransformer with class name 'NSKeyedUnarchiveFromDataTransformerName' was found for attribute 'comments' on entity 'System'
2013-12-11 10:47:10.574 iProject2iOS[5431:5877] CoreData: warning: no NSValueTransformer with class name 'NSKeyedUnarchiveFromDataTransformerName' was found for attribute 'functions' on entity 'System'
2013-12-11 10:47:10.578 iProject2iOS[5431:5877] CoreData: warning: no NSValueTransformer with class name 'NSKeyedUnarchiveFromDataTransformerName' was found for attribute 'details' on entity 'Timesheet'
2013-12-11 10:47:10.608 iProject2iOS[5431:60b] AppDelegate.storesDidChange called - >>>>>>>>>>>>>>>>>>>>>>>>>>>>
2013-12-11 10:47:10.609 iProject2iOS[5431:5877] -[PFUbiquitySwitchboardEntryMetadata setUseLocalStorage:](754): CoreData: Ubiquity: mobile~A3BF465A-15C7-46F2-8C68-AC8F49FD15AB:New Project Local_UUID_4D7AFA0C-3C62-452E-8302-6401ED356478
Using local storage: 1
2013-12-11 10:47:10.794 iProject2iOS[5431:60b] AppDelegate.fileOpened called
2013-12-11 10:47:11.291 iProject2iOS[5431:60b] AppDelegate.storesDidChange called - >>>>>>>>>>>>>>>>>>>>>>>>>>>>
2013-12-11 10:47:11.292 iProject2iOS[5431:60b] OpeningViewController.refreshUI: called
2013-12-11 10:47:11.293 iProject2iOS[5431:60b] MenuViewController.refreshUI: called
2013-12-11 10:47:11.294 iProject2iOS[5431:60b] OpeningViewController. about to call displayItem
2013-12-11 10:47:11.295 iProject2iOS[5431:60b] OpeningViewController. displayItem has been called
2013-12-11 10:47:11.649 iProject2iOS[5431:60af] -[PFUbiquitySwitchboardEntryMetadata setUseLocalStorage:](754): CoreData: Ubiquity: mobile~A3BF465A-15C7-46F2-8C68-AC8F49FD15AB:New Project Local_UUID_4D7AFA0C-3C62-452E-8302-6401ED356478
Using local storage: 0
如果它的本地商店被打开,那么这就是调用序列。因为iCloud不是ON,所以我不期望另外storeDidChange通知。我在Open完成处理程序中设置了一个标志,然后当我得到storesDidChange通知时,如果设置了这个标志,我刷新UI,否则我忽略它(如果iCloud为ON)。如果我们不使用iCloud,我不需要调用refreshUI,因为UI是由Open完成处理程序激活的,此时本地存储可用。
2013-12-11 10:55:26.255 iProject2iOS[5440:60b] AppDelegate.application:didFinishLaunchingWithOptions: called
2013-12-11 10:55:26.259 iProject2iOS[5440:60b] AppDelegate.checkUserICloudPreferenceAndSetupIfNecessary called
2013-12-11 10:55:26.460 iProject2iOS[5440:60b] AppDelegate. User preference for au.com.ossh.iProject2.UseICloudStorage is NO
2013-12-11 10:55:26.462 iProject2iOS[5440:60b] AppDelegate. User disabled iCloud
2013-12-11 10:55:26.464 iProject2iOS[5440:60b] AppDelegate. iCloud is active
2013-12-11 10:55:29.977 iProject2iOS[5440:60b] AppDelegate.loadFile called.
2013-12-11 10:55:29.980 iProject2iOS[5440:60b] AppDelegate.managedObjectModel called.
2013-12-11 10:55:30.190 iProject2iOS[5440:60b] AppDelegate. setting merge policy
2013-12-11 10:55:30.231 iProject2iOS[5440:60b] AppDelegate.storesDidChange called - >>>>>>>>>>>>>>>>>>>>>>>>>>>>
2013-12-11 10:55:30.330 iProject2iOS[5440:60b] AppDelegate.fileOpened called
以下是enabling the UI when using Core Data and iCloud上一些其他详细信息的链接。