Run method in background

by alex 15. April 2009 01:49

[NSThread detachNewThreadSelector:@selector(doSomethingInBack:) toTarget:self withObject:nil];

 

-(void) doSomethingInBack:(id)anObject {

NSAutoreleasePool *autoreleasepool = [[NSAutoreleasePool alloc] init];

 

//place code you want to run in different thread HERE

 

[NSThread exit];

//we need to do this to prevent memory leaks

[autoreleasepool release];

}

Currently rated 4.6 by 5 people

  • Currently 4.6/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

General

Powered by BlogEngine.NET 1.4.5.0
Theme by Mads Kristensen