Daily Snippet

Concurrency. And concurrency. And once again: concurrency. The holy grail to writing good Apps. And the hardest part. At least to debug.

The simplest way to performe a task not on the main thread is:

[self performSelectorInBackground:@selector(myConcurrentAction) withObject:nil];

- (void) myConcurrentAction {
NSAutoreleasePool *pool = [NSAutoreleasePool new];

// do whatever needs to be done
// but only all things NOT GUI
// ensure that nothing else tries to access used objects meanwhile

[pool drain];
}

  1. do-nothing reblogged this from moapp
  2. moapp posted this