ARC,值得与否? [英] ARC, worth it or not?

查看:102
本文介绍了ARC,值得与否?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我从C ++(和小Java)转移到Objective C(iOS)时,我很难理解iOS中的内存管理。但现在这一切看起来很自然,我知道保留,自动释放,复制和发布的东西。在阅读了ARC之后,我想知道使用ARC有什么好处,或者只是你不必担心内存管理。在转向ARC之前,我想知道如何转向ARC。

When I moved to Objective C (iOS) from C++ (and little Java) I had hard time understanding memory management in iOS. But now all this seems natural and I know retain, autorelease, copy and release stuff. After reading about ARC, I am wondering is there more benefits of using ARC or it is just that you dont have to worry about memory management. Before moving to ARC I wanted to know how worth is moving to ARC.


  1. XCode有转换为Objective C ARC菜单。转换是否那么简单(没什么可担心的)?

  2. 它是否有助于我减少我的应用程序内存占用空间,内存泄漏等(不知何故?)

  3. 它对我的应用程序有多大的测试影响?

  4. 什么是非显而易见的优势?

  5. 移动到它的任何不利之处?

  1. XCode has "Convert to Objective C ARC" menu. Is the conversion is that simple (nothing to worry about)?
  2. Does it help me in reducing my apps memory foot-print, memory leaks etc (somehow ?)
  3. Does it has much testing impact on my apps ?
  4. What are non-obvious advantages?
  5. Any Disadvantage of moving to it?


推荐答案

以下是我对ARC的具体看法:

Here's my specific take on ARC:


1)XCode具有转换为Objective C ARC菜单。转换是否那么简单(没什么可担心的)?

1) XCode has "Convert to Objective C ARC" menu. Is the conversion is that simple (nothing to worry about)?

这很简单。有用。用它。正如Kevin Low指出的那样,你需要经历并修复使用Core Foundation对象的位。这只需要健康绑定 __ bridge __ bridge_transfer 但是。

It's simple. It works. Use it. As Kevin Low points out though, you will need to go through and fix up the bits where you use Core Foundation objects. That will just require a healthy lashing of __bridge or __bridge_transfer though.


2 )它是否有助于我减少我的应用程序内存占用空间,内存泄漏等(不知何故?)

2) Does it help me in reducing my apps memory foot-print, memory leaks etc (somehow ?)

不,不是真的。好的,有点儿。它有助于减少以前编码错误的内存泄漏。它不会减少内存占用。

Nope, not really. OK, sort of. It will help reduce memory leaks where you have coded incorrectly previously. It won't reduce memory footprint.


3)它对我的应用程序有多大的测试影响?

3) Does it has much testing impact on my apps ?

无论如何。


4)什么是非显而易见的优势?

4) What are non-obvious advantages?

未来。将会有更多的奖励,即编译器对如何计算引用的对象提供了复杂的知识。例如,ARC提供了可爱的 objc_retainAutoreleasedReturnValue 优化已经非常好了。

The future. There'll be more to come on the bonus that the compiler taking an intricate knowledge of how objects are reference counted gives. For example ARC provides the lovely objc_retainAutoreleasedReturnValue optimisation already, which is very nice.


5)任何不利因素都会转移到它?

5) Any Disadvantage os moving to it?

无论如何。

请接受我的话并开始使用弧。没有理由(IMO)没有,因此优势肯定超过了劣势!

Please take my word for it and start using ARC. There's no reason (IMO) not to, thus the advantages definitely out-weigh the disadvantages!

深入了解ARC如何工作或许有助于说服你这很好,请看看我的博客文章在ARC的引擎盖下看看 - 这里这里这里& 此处

For an in-depth look at how ARC works to perhaps help convince you that it's good, please take a look at my blog posts entitled "A look under ARC's hood" - here, here, here & here.

这篇关于ARC,值得与否?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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