Skip to content

Instantly share code, notes, and snippets.

@ikarius
Created July 27, 2011 12:18
Show Gist options
  • Select an option

  • Save ikarius/1109234 to your computer and use it in GitHub Desktop.

Select an option

Save ikarius/1109234 to your computer and use it in GitHub Desktop.

Revisions

  1. ikarius created this gist Jul 27, 2011.
    35 changes: 35 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,35 @@
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16



    - (void) loadData {
    dataLoaded = NO;
    NSLog(@" thread launched");
    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
    [self loadDataFromURL:nil];
    dataLoaded = YES;

    // reload de la tableview dans le thread principal:
    [self.tableView performSelectorOnMainThread:@selector(reloadData) withObject:nil waitUntilDone:YES];
    // plutot que:
    // [self.tableView reloadData];

    [pool release];
    }

    // Et si tu veux éviter les pools, tu peux aussi utiliser les NSOperationQueue / NSOperation