stackmob/stackmob-ios-sdk — pull request #24 by JJJayway (2012-11-30 09:15:13+00:00)
Title: Fix synchronization and callback handling

As the context is an `NSPrivateQueueConcurrencyType`, use of it should ALWAYS be wrapped in `-performBlock(AndWait)`. This could deadlock previously as callbacks were executed on the main queue (which would e.g. be blocked in `-[NSFetchedResultsController objectAtIndexPath:]`).

Also, when not using the context directly from the main thread, long delays would occur, as `syncWithSemaphore()` would run a runloop for 10 seconds between completion checks. The run loop appears to be either a leftover, or a hack to enable callbacks on the main thread while (mis-)using the context on the main thread.