在单独的线程上运行代码的最佳方式是什么?是不是:
[NSThread detachNewThreadSelector: @selector(doStuff) toTarget:self withObject:NULL];
或者:
NSOperationQueue *queue = [NSOperationQueue new];
NSInvocationOperation *operation = [[NSInvocationOperation alloc] initWithTarget:self
selector:@selector(doStuff:)
object:nil;
[queue addOperation:operation];
[operation release];
[queue release];
我一直在用第二种方法,但我一直在读的韦斯利烹饪书使用了第一种方法.