问题描述
作为一名初级iPhone程序员,编写iOS 5或更早版本的应用程序的最佳做法是什么?具体来说,我应该继续使用数据的发布/保留,还是应该忽略它?这有关系吗?
这取决于你。您可以使用ARC(自动引用计数)编写应用程序,Xcode将编写粘合代码以允许启用ARC的应用程序在iOS 4上运行,无需修改。但是,某些事情不会起作用,并且最明显的许多库你可能希望(有时)抛出无数错误,在开发人员发布与ARC兼容的更新之前,你将无法使用它们。
编辑:我最近发现您可以基于每个文件关闭ARC。请参阅。
As a beginning iPhone programmer, what is the best practice for writing apps to be used either with iOS 5 or older versions? Specifically, should I continue using the release/retain of data, or should I ignore that? Does it matter?
It's up to you. You can write apps using ARC (Automatic Reference Counting), and Xcode will write "glue code" to allow your ARC enabled apps to run on iOS 4, no modifications required. However, certain things wont work, and most noticeably many libraries you might wish to use will (sometimes) throw up innumerable errors and you will be unable to use them until the developers release an update which is compatible with ARC.
Edit: I recently discovered that you can turn off ARC on a per-file basis. See pixelfreak's answer. So, my advice still stands, but now the 3rd-party libraries shouldn't need to be updated to work with ARC.
Here's what Apple says about opting out of ARC for specific files:
See the full transition guide here.
这篇关于iOS 5最佳实践(发布/保留?)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!