nspersistentcontainer

How to Migrate Core Data's Data to App Group's Data

筅森魡賤 提交于 2020-06-11 11:47:53
问题 I just added App Groups to my app using this StackOverFlow post. Unfortunately since the defaultDirectoryURL is changing, I can not fetch any of the old data I made before using the App Groups directory. I know the data is still there because when I switch back to using a regular NSPersistentContainer instead of the GroupedPersistentContainer , I can get the data. How can I migrate my old data over to where I'm fetching the app group's data? Core Data code: class CoreDataManager { static let

How to Migrate Core Data's Data to App Group's Data

淺唱寂寞╮ 提交于 2020-06-11 11:46:16
问题 I just added App Groups to my app using this StackOverFlow post. Unfortunately since the defaultDirectoryURL is changing, I can not fetch any of the old data I made before using the App Groups directory. I know the data is still there because when I switch back to using a regular NSPersistentContainer instead of the GroupedPersistentContainer , I can get the data. How can I migrate my old data over to where I'm fetching the app group's data? Core Data code: class CoreDataManager { static let

ViewContext not receiving updates from newBackgroundContext()

风格不统一 提交于 2019-12-08 16:43:21
问题 There is a similar question in stack overflow already but it doesn't work for me. There is a use case in my application where I have to observe the database changes to perform some operation. To receive updates I subscribed to NSManagedObjectContextObjectsDidChange notification (for ViewContext) and also I turned on automaticallyMergesChangesFromParent . But, if I update or delete the object on some other context (using newBackgroundContext() ), I don’t receive object did change notification