是否支持iPhone应用程序的垃圾回收? [英] Is garbage collection supported for iPhone applications?

查看:129
本文介绍了是否支持iPhone应用程序的垃圾回收?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

iPhone支持垃圾回收吗?如果是,那么使用 + alloc -init 组合执行操作的替代方法是什么:

Does the iPhone support garbage collection? If it does, then what are the alternate ways to perform the operations that are performaed using +alloc and -init combination:

NSXMLParser *xmlParser = [[NSXMLParser alloc] initWithData:xmlData];
UIImage *originalImage = [[UIImage alloc] initWithData:data];
detailViewController = [[[DetailViewController alloc] initWithNibName:@"DetailView bundle:[NSBundle mainBundle]] autorelease];


$

推荐答案

p>否。垃圾收集太大,对于设备上的有限电池寿命等而言是开销。

No. Garbage collection is too large an overhead for the limited battery life etc. on the device.

您必须始终使用 alloc / release 模式。

NSXMLParser *xmlParser = [[NSXMLParser alloc] initWithData:xmlData];
...
[xmlParser release];

对于每种情况)

NSXMLParser *xmlParser [[[NSXMLParser alloc] initWithData:xmlData] autorelease];

希望这有助于!

这篇关于是否支持iPhone应用程序的垃圾回收?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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