好了,这里是我的问题......奇怪的问题与宏和ARC
我的宏定义
#define DRK_INIT(X) -(id)init \
{ \
self = [super init]; \
if (self) { \
X \
} \
return self; \
}
#define DRK_DEALLOC(X) -(void)dealloc \
{ \
X \
[super dealloc]; \
}
#define DRK_DICFROMFILE(X) [NSDictionary dictionaryWithContentsOfFile:(X)]
#define DRK_MUTDICFROMFILE(X) [NSMutableDictionary dictionaryWithContentsOfFile:(X)]
#define DRK_ARRFROMFILE(X) [NSArray arrayWithContentsOfFile:(X)]
#define DRK_MUTARRFROMFILE(X) [NSMutableArray arrayWithContentsOfFile:(X)]
#define DRK_STRFROMFILE(X) [NSString stringWithContentsOfFile:(X) encoding:NSUTF8StringEncoding error:nil]
#define DRK_WRITESTRTOFILE(X,Y) [(X) writeToFile:(Y) atomically:YES encoding:NSUTF8StringEncoding error:nil]
#define DRK_WRITEDICTOFILE(X,Y) [(X) writeToFile:(Y) atomically:YES]
#define DRK_WRITEARRTOFILE(X,Y) [(X) writeToFile:(Y) atomically:YES]
现在,当我试图使用它们(完全一样时,我是不使用ARC),这样,我不断收到警告:
// Type specifier missing, defaults to 'int'
DRK_INIT();
- (void)someFunction:(NSString*)str
{
// Implicit conversion of 'int' to 'NSString *' is disallowed with ARC
[self setContent:DRK_STRFROMFILE(str)];
}
任何想法是怎么回事?如何消除所有这些 - 实际上是无害的 - 警告/错误?
提示:
- 请注意,整个事情是仍处于工作状态,但转换成ARC之后,不断出现一些警告/错误。
- 我跑的Xcode 4.5.1,Mac OS X的10.7.5(狮子),并与LLVM 4.1
好奇你为什么以这种方式使用宏... – nielsbot 2013-02-20 11:50:24
调用' - [super dealloc]'不允许使用ARC – nielsbot 2013-02-20 11:53:11
无论如何,我不会像上面那样使用你的DRK_INIT()检查你的源之前,该点出错... – nielsbot 2013-02-20 11:53:58