When discussing about the Export Operations (and operations in general that we may need to perform with our managed objects) it is explained that, as much as possible, work should be shipped to a background queue to not affect the UI thread.
Yet on the
PPRDetailViewController.swift file, at the end of the
mailRecipe() method, the operation is added to the main queue. This confuses me a bit, because the operation’s
main() seems to expect to be run under a non-main queue (since it avoids using anything other than the
objectId, and it uses its own MOC.)
On the other hand, the code calls
performBlockAndWait(), so that block is indeed run on a background thread.
Or that’s what I thought, but when I ran the code to confirm my guess, I was surprised to find that the block was running on the main thread o_O I thought I understood operation queues, but I am now more confused than ever
So, in order to ship work to a background thread, should I:
- add the operations to a background queue?
- or, it does not matter since the
performBlock…methods will take care of running that work on the thread of the child MOC anyway?