Search code examples
iosmagicalrecord

What is localContext in MagicalRecord?


Sometimes in my app I use MagicalRecord blocks like

[MagicalRecord saveWithBlockAndWait:^(NSManagedObjectContext *localContext){}];

I want to ask, what localContext is? Is it my [AppDelegate sharedContext] or what?


Solution

  • Check out the tutorial on github https://github.com/magicalpanda/MagicalRecord/blob/master/Docs/Working-with-Managed-Object-Contexts.md

    MagicalRecord provides methods to set up and work with contexts for use in background threads. The background saving operations are inspired by the UIView animation block methods, with a few minor differences:

    The block in which you make changes to your entities will never be executed on the main thread. A single NSManagedObjectContext is provided for you within these blocks.