I had this code at the start of my application, which worked fine before:
MagicalRecord.setupCoreDataStack()
let context = NSManagedObjectContext.MR_context()
let predicate = NSPredicate(format: "sendStatus = \(MessageSendStatus.Sending.rawValue)")
let messages = Message.MR_findAllWithPredicate(predicate, inContext: context) as! Array<Message>
I then handle those messages.
Upon updating, the code changed as follows:
MagicalRecord.setupClassicStack()
let context = NSManagedObjectContext.MR_context()
let predicate = NSPredicate(format: "sendStatus = \(MessageSendStatus.Sending.rawValue)")
let messages = Message.MR_findAllWithPredicate(predicate, inContext: context) as! Array<Message>
Only the first line changed. But now when I run it, I get a crash on that last line:
*\ Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '+entityForName: nil is not a legal NSPersistentStoreCoordinator for searching for entity name 'Message''
I tried changing the context declaration to NSManagedObjectContext.MR_mainQueueContext(), just for testing it out, but it still produced the same error. Removing the inContext: argument from that last line works, but I'd guess it's not advised, as it'd then just cause problems:
I can't save the context, since I don't have it, other than taking it from a message. That's a bit messy, since I save after handling all of them.
The context may not be generated correctly for the thread.
I had this code at the start of my application, which worked fine before:
I then handle those messages.
Upon updating, the code changed as follows:
Only the first line changed. But now when I run it, I get a crash on that last line:
I tried changing the context declaration to
NSManagedObjectContext.MR_mainQueueContext()
, just for testing it out, but it still produced the same error. Removing theinContext:
argument from that last line works, but I'd guess it's not advised, as it'd then just cause problems:What am I doing wrong?