disabling ARC for .h files iphonesdk

2019-07-16 07:25发布

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;

It causes an error like

ARC forbids object in struct or union

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

1条回答
Anthone
2楼-- · 2019-07-16 08:14

I would use something like this:

#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;
查看更多
登录 后发表回答