One often need to to perform different tasks simultaneously without blocking the interface - for example an up or download can be done in the background or an auto-save task can be processed while the user is still writing or generating a Quick Look should not be done in the main thread. Creating a new thread is very easy:
[NSThread detachNewThreadSelector:@selector(myThreadMethod)
toTarget:self
withObject:nil];
All you have to do then is to create the method that is called by the new thread:
- (void)myThreadMethod
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
// do this or that
[pool release];
}
Click here for the new weblog.