您的位置:首页 > 其它

nsthread autoreleased with no pool in place – just leaking警告的解决方法

2013-03-06 10:40 447 查看
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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐