-1
我写下面的代码。NSThread问题如何解决?
#import <objc/objc.h>
#import <Foundation/Foundation.h>
@interface myT :NSObject
-(void) startT;
-(void) tfun;
@end
@implementation myT
-(void) tfun
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
NSLog (@"Inside thread Function .. ");
[pool drain];
}
-(void) startT
{
[NSThread detachNewThreadSelector:@selector(tfun) toTarget:self withObject:nil ];
}
@end
int main (int argc, char ** argv)
{
myT *t = [[myT alloc] init];
[t startT];
return 0;
}
它编译,并导致运行时错误。我做错了什么?我熟悉pthread。我如何等待线程完成,即:pthread_wait类。
后错误日志 – Saphrosit 2012-04-14 16:09:51