Question

I am new to using background threads to display data in the iOS UI.

I am now using the Parse SDK for all of my backend data management. It seems all of the Parse methods return data asynchronously for the iOS version of the SDK. If the data is not going to be returned immediately, but in a background thread, how do I implement data returned in the UI?

For example,

I want to show a title in a view in iOS. The text content of the title is stored in Parse and is retrieved via a service that is run on a background thread. How do I update the title when the data is available from the return block?

Was it helpful?

Solution

Insert this code into your background code:

dispatch_async(dispatch_get_main_queue(), ^{
             // update UI here
             //...
         });

You can only update the UI via the main thread (or so I've been told).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top