Reputation: 11493
I am fetching items asynchronously using blocks from different sources like …
After the data fetching for each source is finished I post a notification and immediately add respective items as subviews.
The problem: Items/views only get displayed after a delay of a couple of seconds, sometimes even longer (long after getting the actual result response). This is not the case for the synchronously fetched items like for calendar events – they show up immediately.
(Curiously using the new Xcode6 live view debugger I can see the new item views there but not in the actual simulator or device.)
Could this have something to do with async fetches not happening on the main queue? Is there anyway to change this async behaviour have all results show up as generated views immediately?
Upvotes: 1
Views: 102
Reputation: 437592
When you post the notification, are you dispatching that to the main queue? If not, does your handler dispatch the UI updates to the main queue?
When you post a notification from a background thread, the handler is called on a background thread. Thus, if you try to do UI updates in response to a notification sent from a background thread without dispatching the UI updates back to the main queue, you'll see the sort of behavior you describe.
Upvotes: 1