8

我有一个想要迁移到 ARC 的 OSX 应用程序。如果我将基本 SDK 设置为 10.7,一切正常。但是当我将它设置为 10.6 时它不起作用(因为它没有找到 _objc_release 等)。那么如何在启用 ARC 的情况下将我的应用程序部署到 10.6?

4

2 回答 2

12

You set the SDK to 10.7 but the Deployment Target to 10.6.

Keep in mind:

While it's possible to build programs using ARC that run on Mac OS X 10.6 and iOS 4, zeroing weak references are not available on those OSes. All weak references must be __unsafe_unretained here. Because non-zeroing weak references are so dangerous, this limitation significantly decreases the attractiveness of ARC on those OSes in my view.

Source: Automatic Reference Counting

于 2011-10-08T11:36:33.580 回答
7

您可能会发现 PLWeakCompatibility 很有用。它允许您在 iOS 4 和 OS X 10.6 上使用 __weak 变量。

源代码在这里:https
://github.com/plausiblelabs/PLWeakCompatibility 更多信息在http://www.mikeash.com/pyblog/introducing-plweakcompatibility.html

于 2012-05-14T06:05:01.230 回答