将非ARC文件子类化为Xcode 4中的ARC项目 [英] Subclass non-ARC file into ARC project in Xcode 4

查看:104
本文介绍了将非ARC文件子类化为Xcode 4中的ARC项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在ARC项目中使用了一些非ARC代码,即Three20。我添加了所有适当的编译器标志,一切正常。但是,我需要继承一些Three20类中的一些,并且我不确定是否应该将编译器标志添加到非ARC的新文件中,或者如果编译器将其解决,并添加适当的释放调用。

I am using some non-ARC code in my ARC project, namely Three20. I have added all the appropriate compiler flags and all works well. However, I need to subclass some of the Three20 classes, and I'm not sure if I should add the compiler flag to my new file for non-ARC, or if the compiler will figure it out, and add the appropriate release calls.

回顾一下:
- XCode 4中的ARC项目
- 包括非ARC代码(Three20)
- 需要子类在非ARC文件中定义的内容
- 我是否需要添加发布调用?
- 我是否需要在子类中为非ARC添加编译器标志?

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?

推荐答案

Michael,

ARC是一种编译时技术,它根据内存中的给定插槽是否将持续超出当前方法/函数调用来确定保留/释放语义。因此,您可以安全地使用ARC混合子类。我一直这样做。我也是按类别来做的。与垃圾收集不同,ARC非常关注每个方法/功能中的存储空间。顺便说一下,iOS的大多数框架似乎还没有使用ARC。因此,您构建框架类的任何子类都有这个问题而且它不是问题。

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.

回答您的具体问题:


回顾一下: - XCode 4中的ARC项目 - 包括非ARC代码
(Three20) - 需要子类化非ARC中定义的内容文件 - 我需要增加发布电话吗? - 我是否需要在子类中为
非ARC添加编译器标志?

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?

您的非ARC超类的子类可以是ARC也可以不是。由于您的应用的默认设置是ARC,因此您无需对子类执行任何操作。

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

这篇关于将非ARC文件子类化为Xcode 4中的ARC项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆