开发者

Prepare for ARC - best strategy?

For an OS X app for Lion, 64-bit only, I was wondering what the best strategy is in order to be prepared to take the app to ARC later on:

  • Do normal retain/release and simply remove it all later
  • Use automatic garbage collection and hope the changes needed later will be minimal

Any advice appre开发者_运维知识库ciated!


The only preparation necessary is to:

  1. Write modular code (hopefully, you're doing this already).
  2. Ensure you're following Cocoa memory management and naming conventions.

ARC can be activated on a per compilation unit basis, and will happily interact with non-ARC code that has these properties. You can thus adopt it gradually.

There's a good video on ARC adoption in the WWDC 2011 videos, titled "Introducing Automatic Reference Counting". I can't link right to it (it's behind an access control wall, and you'll need an Apple developer account).


Don't do GC. It's not recommended for new apps anymore, and it's a bigger conceptual jump to ARC than manual reference counting is.

I'd just use ARC in the first place, but if you really want to write the program in something else and then convert it, use MRC. Xcode offers an automatic converter for this.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜