0
votes

I am confused with the documentation expain about the performBlock: and PerformBlockAndWait: It says: performBlock is async and withWait:is sync in the receiver's queue. Is that "receiver" refers to the NSManagedObjectContext? If the context is private type so the block executes in the background thread, if the context is main type and the block executes in the main thread? many thanks

2

2 Answers

0
votes

Exactly. You understood the documentation correctly.

"Receiver" refers to the existing context, so if this is a background context, the block will be executed in a background thread, if it is a main context, on the main thread.

0
votes

Both methods will perform the block on the context's queue (on a background thread, in the case of a private queue context). However, the performBlockAndWait: method will ALSO block the calling thread until the block has finished executing on the background thread.