自动参考计数(ARC)中的NSThreads [英] NSThreads in Automatic Reference Counting(ARC)

查看:109
本文介绍了自动参考计数(ARC)中的NSThreads的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在4.3.5中使用带有ARC的NSThreads。使用iOS 5一切都很完美,但如果我在较旧的iOS上尝试它,如4.3它的泄漏。通常我会为NSThreads使用Autoreleasepool,但由于ARC中没有手动Autoreleasepool,我不知道如何解决这个问题。

i am trying to use NSThreads with ARC in 4.3.5. With iOS 5 everything works perfect, but if i try it on a older iOS like 4.3 its leaking. Normally i would use a Autoreleasepool for NSThreads but since there is no manual Autoreleasepool in ARC i don't know how to fix this.

我收到大量的消息,如__NSAutoreleaseNoPool ():类NSComparisonPredicate的对象0x4567b40自动释放,没有池到位 - 在我启动一个线程后在我的控制台中泄漏。

I get loads of Messages like "__NSAutoreleaseNoPool(): Object 0x4567b40 of class NSComparisonPredicate autoreleased with no pool in place - just leaking" in my Console after i start a Thread.

NSThread detachNewThreadSelector:@selector(showAlert) toTarget:self withObject:nil];

如何在5.0之前正确使用ARC和iOS。

How to correctly thread with ARC and iOS prior to 5.0.

干杯
nettz

Cheers nettz

推荐答案

-(void)showAlert
{
    @autoreleasepool {
        // Your code.
    }
}

这篇关于自动参考计数(ARC)中的NSThreads的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆