线程(重要基础知识)

1. 创建一个新的线程:
[NSThread detachNewThreadSelector:@selector(myMethod)
        toTarget:self
        withObject:nil];
 2. 创建线程所调用的方法:
- (void)myMethod {
    NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
*** code that should be run in the new thread goes here *** [pool release];
}
假如我们需要在线程里面调用主线程的方法函数,就可以用
performSelectorOnMainThread来实现:
[self performSelectorOnMainThread:@selector(myMethod)
    withObject:nil
    waitUntilDone: false ];
posted on 2013-04-06 15:34  junxiaohu  阅读(118)  评论(0)    收藏  举报