Reputation: 457
I have a Core Data, called TaskManager
, On this CoreData at the moment only one Entity, Task
: Task got severals attributes:
import Foundation
import CoreData
@objc(Task)
class Task: NSManagedObject {
@NSManaged var context: String
@NSManaged var date: String
@NSManaged var detail: String
@NSManaged var id: String
@NSManaged var responsable: String
@NSManaged var status: String
@NSManaged var summary: String
}
If I add a new Entity , for example User
:
import Foundation
import CoreData
@objc(User)
class User: NSManagedObject {
@NSManaged var id: String
@NSManaged var name: String
}
and I Reset contents and settings...
from the emulator to let it know the new Entity, my application starts but I can't do anything, it's just frozen, can't click on buttons, the UITableView scroll doesn't work, when I stop the emulator to uninstall the application I can't, holding left click does nothing... I have to delete the Entity from my coredata, move to trash the NSManagedObject
User auto generated by my Core Data, close the emulator, restart everything and there it works again, but what I need is to work with this other entity, User, so deleting it is... quite dumb..
How am I supposed to do to create the new Entity without freezing all the application?
Thank you for your help.
Regards. Fselva
Upvotes: 0
Views: 759
Reputation: 1262
Each time you change your data model, you must uninstall your app on the device or on the simulator. Thus, in the next build and run, the updated DB will be loaded. Of course, you lose all the data being loaded in the precedent version.
Upvotes: 2