Core Data and Magical Record saving

This is somewhat of a basic question, but need some clarification.

I have this piece of code.

   //line of code #1

[localContext MR_saveToPersistentStoreWithCompletion:^(BOOL success, NSError *error) {

   //line of code #2


Is the line of code #2 the completion block? Should I make my changes to an entity prior to the save as line of code #1 shows?



Anything with the form of ^(…) { … } or ^{ … } is a block. In essence, a block is portable a chunk of code which is not directly executed. A block can be saved to a variable then execute at a later point in time.

typedef void (^my_block_t)();
my_block_t myBlock = ^{
    NSLog(@"I'm in a block");

Here's a block which prints a log statement. The block is saved to the variable myBlock. Note: at this point in time, NSLog does not print out anything.

At some point in time later, myBlock can be execute.


At this point in the code, the block is run and NSLog prints out it's statement.

If your example, the execution of line of code #2 is delayed until after the save has completed.

Logically, it works the same as:

Step 1) execute line of code #1 Step 2) execute save Step 3) execute line of code #2

Because things in line of code #2 happen after the save has completed, then any changes to the model would not be saved at that point.

Need Your Help

Reduce Grid visibility in Windows Form Chart

c# winforms

Hi i am using Bar chart in windows form application . It shows line grid behind bar area my client wants two changes 1: change grid from line to dotted view and grid style should be dark grey shade...

See checkbox value when checked

html checkbox

If i have a list of checkboxes and they have the same name and different values.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.