I've seen two different ways of doing this and I'd like to know which is correct.
Specifically I'm talking about accessing the ManagedObject
on the BG thread.
The methods I have seen are...
Person *person = ...
[MagicalRecord saveUsingBlock:^(NSManagedObjectContext *localContext) {
Person *localPerson = [person inContext:localContext];
// do stuff...
}]
But I've also seen...
Person *person = ...
NSManagedObjectID *objectID = person.objectID;
[MagicalRecord saveUsingBlock:^(NSManagedObjectContext *localContext) {
Person *localPerson = (Person*)[localContext objectWithID:objectID];
// do stuff...
}]
The latter seems more correct as you're not trying to access the object across threads. But having seen both I wasn't sure if MagicalRecord
did something Magical to get around this?