禁用.h文件的ARC iphonesdk
我的项目使用ARC,我想使用与ARC不兼容的GDataAPI。 我知道如何为单个文件禁用ARC(通过为这些文件添加-fno-objc-ARC编译器标志)。但是在GDataObject.h文件中有一个结构防御禁用.h文件的ARC iphonesdk,iphone,automatic-ref-counting,gdata-api,Iphone,Automatic Ref Counting,Gdata Api,我的项目使用ARC,我想使用与ARC不兼容的GDataAPI。 我知道如何为单个文件禁用ARC(通过为这些文件添加-fno-objc-ARC编译器标志)。但是在GDataObject.h文件中有一个结构防御 typedef struct GDataDescriptionRecord { NSString *label; NSString *keyPath; enum GDataDescRecTypes reportType; } GDataDescriptionRecor
typedef struct GDataDescriptionRecord {
NSString *label;
NSString *keyPath;
enum GDataDescRecTypes reportType;
} GDataDescriptionRecord;
它会导致如下错误:
ARC forbids object in struct or union
我怎样才能避免这个问题。
是否有任何与ARC兼容的GDATA api可用,或者有任何方法可以禁用.h文件的ARC我会使用以下方法:
#if __has_feature(objc_arc)
#define ARC_MEMBER __unsafe_unretained
#else
#define ARC_MEMBER
#endif
typedef struct GDataDescriptionRecord {
ARC_MEMBER NSString *label;
ARC_MEMBER NSString *keyPath;
enum GDataDescRecTypes reportType;
} GDataDescriptionRecord;
然后,您的结构将如下所示:
#if __has_feature(objc_arc)
#define ARC_MEMBER __unsafe_unretained
#else
#define ARC_MEMBER
#endif
typedef struct GDataDescriptionRecord {
ARC_MEMBER NSString *label;
ARC_MEMBER NSString *keyPath;
enum GDataDescRecTypes reportType;
} GDataDescriptionRecord;
可能重复的