magicalpanda / MagicalRecord

Super Awesome Easy Fetching for Core Data!
Other
10.8k stars 1.79k forks source link

crash after impl. a new Data model #1168

Open mbeloded opened 8 years ago

mbeloded commented 8 years ago

i found a crash after updating a Data model, for example when i add a new field in some entity. Crash in line #64 of class MagicalRecordStack - "NSAssert([self store], @"No NSPersistentStore initialized for stack [%@]", stackType);". So, in such cases the stak is nil. I wrote some workaround and can share updated class with you. It works for me, hope you'll accept ith my solution. MagicalRecordStack.m.zip

jweihs commented 8 years ago

Hello @mbeloded , are you using any type of migration to update your data model? One possibility is to use lightweight migration. Before changing the entities, you have to create a new data model version (Editor->Add Model Version..). (https://developer.apple.com/library/ios/documentation/Cocoa/Conceptual/CoreDataVersioning/Articles/vmLightweightMigration.html) Otherwise, it will crash like you've described due to inconsistent data models.

mbeloded commented 8 years ago

Editor->Add Model Version - did that, but it was crashed

Michael Bielodied mbeloded@gmail.com

On Jan 15, 2016, at 4:18 PM, jweihs notifications@github.com wrote:

Editor->Add Model Version

jweihs commented 8 years ago

And have you switched your "current Model Version" to the newly created one as well in your .xcdatamodeld before updating your entities? How are you setting up your Magical Record Stack? With setupAutoMigratingStack or their equivalent?