small medium large xlarge

Generic-user-small
28 Sep 2016, 20:07
Predrag Pavlovic (1 post)

Hi Marcus,

In PPRNetworkOperation, you have used:

moc.performBlockAndWait { do { try moc.save() } catch { fatalError(“Failed to save child context: (error)”) } }

Why we need to wait for the block to finish? Could performBlock be used instead as this is private queue context?

Avatarsmall_pragsmall
17 Oct 2016, 20:14
Marcus S. Zarra (284 posts)

Yes, you can definitely use performBlock instead. However that will change the behavior slightly.

In my version, a completionBlock will fire after the context has saved.

If you use a performBlock, the completionBlock will fire before the context saves.

Up to you to decide if that matters in your code base.

You must be logged in to comment