Background multithreading

Discussion in 'iOS Programming' started by mraheel, Mar 7, 2010.

  1. mraheel macrumors regular

    Apr 18, 2009
    Hi Guys,
    I really couldnt understand much on multithreading. When you want things to be updated without the whole app getting stuck. A simple function to implement multithreading..

    Code starts with Creating and Showing a "Loading.." View. And following by removing it after 2 seconds.
    Meanwhile Im trying to query the SQL and add it to an array and reload the tableView.

    How would I be able to do that.. using, i think "performSelector in Background" thread or something. I dont quite know how to implement the whole thing..

    LoadingView *loadingView = [LoadingView loadingViewInView:[self.view.window.subviews objectAtIndex:0] withMessage:@"Loading..."];
    [appDelegate loadLabsOfCategory:CurrentTabSelected containingString:nil animated:YES];
    [self.tableView reloadData];
    any help is appreciated.. as always.
  2. dejo Moderator


    Staff Member

    Sep 2, 2004
    The Centennial State
  3. firewood macrumors 604

    Jul 29, 2003
    Silicon Valley
    Instead of calling any UI method such as reloadData from a background thread, you should queue it up indirectly using performSelectorOnMainThread to pass the message to the main UI thread's run loop.
  4. mraheel thread starter macrumors regular

    Apr 18, 2009
    Okay, so, I will look into more tutorials. At the moment adding performSelectorOnMainThread for reloadData solves my issue? Any example of the sequence would be great.

    But thanks guys, I'll look into that book

Share This Page