"Run method in background"

Mon 11 May 2009

[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];

}