Skip to content

Instantly share code, notes, and snippets.

View vprtwn's full-sized avatar
🌀
𓊍

Ben Guo vprtwn

🌀
𓊍
View GitHub Profile

Common Save Patterns

Standard background save

Assuming that you don't care which NSManagedObjectContext is used, and you just want to make some changes and save them in the background, use the following method. 90% of the time, this is what you'll want.

NSManagedObjectSubclass *myObject = [NSManagedObjectSubclass MR_findFirst];

[MagicalRecord saveWithBlock:^(NSManagedObjectContext *localContext) {