禁用ARC的.h文件iphonesdk [英] disabling ARC for .h files iphonesdk

查看:81
本文介绍了禁用ARC的.h文件iphonesdk的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的项目使用ARC,而我想使用不兼容ARC的GDATA API. 我知道如何禁用单个文件的ARC(通过为这些文件添加-fno-objc-arc编译器标志).但是在GDataObject.h文件中,结构定义为

My projects uses ARC and I want to use GDATA api which is not ARC Compatible. I know how to disable ARC for single file(by adding the -fno-objc-arc compiler flag for those files). But in GDataObject.h file there is a structure defenition as

typedef struct GDataDescriptionRecord {
    NSString *label;
    NSString *keyPath;
    enum GDataDescRecTypes reportType;
} GDataDescriptionRecord;

它会导致类似

ARC forbids object in struct or union

如何避免此问题. 是否有可用的ARC兼容GDATA API或以任何方式为.h文件禁用arc

How can I avoid this problem. Is there any ARC compatible GDATA api available or any way to disable arc for .h files

推荐答案

我会使用以下内容:

#if __has_feature(objc_arc)
#define ARC_MEMBER __unsafe_unretained
#else
#define ARC_MEMBER 
#endif

然后,您的结构将如下所示:

Then, your structure would look something like this:

typedef struct GDataDescriptionRecord {
    ARC_MEMBER NSString *label;
    ARC_MEMBER NSString *keyPath;
    enum GDataDescRecTypes reportType;
} GDataDescriptionRecord;

这篇关于禁用ARC的.h文件iphonesdk的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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