How to load something in another thread?

        // show something that let user know that app is working on something. This will do the trick http://swiftcodes.eu/example/showing-loading-circle-animation-programmatically/ 
        dispatch_async(dispatch_get_global_queue( DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), {
            //Load something here. Notice this is not main thread and you can't change anything in UI from here.
            dispatch_async(dispatch_get_main_queue(), {
                //update UI in main thread once the loading is completed.
                });
            })
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s