Translate

Wednesday 13 November 2013

Dispatch Queue

dispatch_queue_t jsonParsingQueue = dispatch_queue_create("jsonParsingQueue", NULL);
//the name can be anything background 


// execute a task on that queue asynchronously on background 
dispatch_async(jsonParsingQueue, ^{

      [self citySearchArrayMethod]; // populates the city table with city list

    // some code on a main thread (delegates, notifications, UI updates...) 

    dispatch_async(dispatch_get_main_queue(), ^{

      [self.tableView reloadData]; // load the table with data

    });
});

No comments:

Post a Comment