Subclass non-ARC file into ARC project in Xcode 4

你。 提交于 2019-12-03 08:47:20

Michael,

ARC is a compile time technology that determines retain/release semantics based upon whether a given slot in memory will persist beyond the current method/function invocation. Because of this, you can safely intermix subclasses using ARC or not. I do it all of the time. I also do it in categories. Unlike garbage collection, ARC is quite focussed on just the storage space in each method/function. BTW, most of iOS's frameworks do not appear to yet use ARC. Hence, any subclass you make of a framework class has this "problem" and it just isn't an issue.

To answer your specific question:

Just to recap: - ARC project in XCode 4 - Includes non-ARC code (Three20) - Need to subclass something defined in non-ARC files - Do I need to add release calls? - Do I need to add compiler flag for non-ARC in subclass?

Your subclass of a non-ARC superclass can be either ARC or not. As the default setting for your app is ARC, you need do nothing to your subclass.

Andrew

Yes, you need to add non-ARC flag (-fno-objc-arc) and retain / release calls.

Don't add it if your subclass does use ARC, but I recommend against this, because it would just be asking for trouble.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!