Run a synchronous method in a background thread

Running a synchronous method in a background thread is a great way of avoiding GUI seeming unresponsive to the user. Getting a file example Get a file //Get file on a background thread to stop GUI locking up dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ NSData* data = [NSData dataWithContentsOfURL:[NSURL URLWithString:@”http://mydomain.com/comefile.php”]]; [self performSelectorOnMainThread:@selector(fetchedData:) withObject:data waitUntilDone:YES]; });   File Received //*********************************** […]

Read More

Updating UI Controls On Background Threads

It is strongly recommended not to update UI controls etc from a background thread (e.g. a timer, comms etc).  This can be the cause of crashes which are sometimes very hard to identify.  Instead use these to force code to be executed on the UI thread (which is always the “main” thread). Dispatch Async And Dispatch Sync […]

Read More