How to Do a Lightweight CoreData Migration in Swift

前端 未结 1 1415
自闭症患者
自闭症患者 2021-02-06 12:30

I am attempting my first lightweight CoreData migration. I read two guides on lightweight migrations. Both add code to a CoreDataStack class, modifying variables like NSPersiste

1条回答
  •  再見小時候
    2021-02-06 12:54

    The migration options need to be used in the call that added the persistent store to the persistent store coordinator. You will easily find this line of code by doing a search for addPersistentStoreWithType.

    try coordinator!.addPersistentStoreWithType(
         NSSQLiteStoreType, configuration: nil, URL: url, options: mOptions)
    

    Most likely your Core Data stack is in the AppDelegate class, but regardless where it is, this is where you have to add the migration options.

    0 讨论(0)
提交回复
热议问题