【发布时间】:2011-06-09 06:06:45
【问题描述】:
#ifdef doesn't work. But why?
CGFloat maxScale;
if ( [[UIScreen mainScreen] respondsToSelector: @selector (scale)] == YES )
{
NSLog (@"case1");
#define GLOBAL1
}
else
{
NSLog (@"case2");
#undef GLOBAL1
}
#ifdef GLOBAL1
NSLog (@"first");
maxScale = 1.0 / [[UIScreen mainScreen] scale];
#else
NSLog (@"second");
maxScale = 1.0;
#endif
#undef GLOBAL1
我的日志:case1,第二个。但首先必须是case1。
【问题讨论】:
-
可能希望修复您的格式。将使其更易于阅读。
-
正确发布代码。不可读。
标签: iphone conditional-compilation