启用ARC但我仍然可以在AppDelegate中使用release和autorelease?

时间:2022-05-13 07:31:14

I have ARC enabled in my iOS application, which I thought meant you weren't able to explicitly call retain, release or autorelease without setting the -fno-objc-arc flag. Apparently this isn't true for the application delegate. I checked my AppDelegate file under the "Compile Sources" section of the "Build Phases" for my project, and it doesn't list any compiler flags set for me AppDelegate file. However, I can explicitly call release and autorelease, but not retain. Is this evidence of witchcraft, or did the Apple engineers resort to hacks to get ARC to work?

我在我的iOS应用程序中启用了ARC,我认为这意味着您无法在不设置-fno-objc-arc标志的情况下显式调用retain,release或autorelease。显然,对于应用程序委托来说,情况并非如此。我在我的项目的“Build Phases”的“Compile Sources”部分下检查了我的AppDelegate文件,它没有列出为我AppDelegate文件设置的任何编译器标志。但是,我可以显式调用release和autorelease,但不能保留。这是巫术的证据,还是苹果工程师采用黑客手段让ARC工作?

1 个解决方案

#1


2  

If you can send these messages, ARC is off.

如果您可以发送这些消息,ARC将关闭。

You can check using

你可以查看使用

#if ! __has_feature(objc_arc)
#error "ARC is off"
#endif

#1


2  

If you can send these messages, ARC is off.

如果您可以发送这些消息,ARC将关闭。

You can check using

你可以查看使用

#if ! __has_feature(objc_arc)
#error "ARC is off"
#endif