Enabling core data lightweight migration in Swift 3

后端 未结 5 860
野的像风
野的像风 2021-02-04 03:01

According to the articles I have read the correct way to enable core data light weight migrations is by passing options to addPersistentStoreWithType:



        
5条回答
  •  傲寒
    傲寒 (楼主)
    2021-02-04 03:25

    You do it using NSPersistentStoreDescription, which is where all those options moved to in the Swift 3 updates. Do this before the call to loadPersistentStores:

    let description = NSPersistentStoreDescription()
    
    description.shouldInferMappingModelAutomatically = true
    description.shouldMigrateStoreAutomatically = true
    
    container.persistentStoreDescriptions = [description]
    

提交回复
热议问题