XXXXX nsthread autoreleased with no pool in place - just leaking
这是一个会经常发生的警告提示。
当调用
[NSThread detachNewThreadSelector:@selector(XXX) toTarget:self withObject:nil];
发起一个多线程的时候会发生这种警告,那么,加上NSAutoreleasePool就可以了,NSAutoreleasePool我的理解是一个自动的进程管理池,当然并不代表着有Java或者AS3的强大GC机制。
[NSThread detachNewThreadSelector:@selector(ooxx) toTarget:self withObject:nil];
- (void)ooxx
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
//OOXX,if you like:)
[pool release];
}
关于NSAutoreleasePool可以查看Apple 的官方文档:NSAutoreleasePool Class Reference
另外,需要注意的是,在多进程中要操作主进程的UI是不可以直接操作的,一定要使用:performSelectorOnMainThread
from:http://hi.baidu.com/liaomingsen/blog/item/d9b71a639b91677b0d33faeb.html