如何在构建设置中定义预处理器宏,如IPAD_build和IPHONE_build(以及如何在我的工厂方法中使用它们)?
我现在把这些都背下来了,如果能知道后面会发生什么就好了.
如何在构建设置中定义预处理器宏,如IPAD_build和IPHONE_build(以及如何在我的工厂方法中使用它们)?
我现在把这些都背下来了,如果能知道后面会发生什么就好了.
/#在以下情况下,if照常工作:
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 30200
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
return YES;
}
#endif
return NO;
}
/#ifdef的意思是"如果已定义-某些值或宏":
#ifdef RKL_APPEND_TO_ICU_FUNCTIONS
#define RKL_ICU_FUNCTION_APPEND(x) _RKL_CONCAT(x, RKL_APPEND_TO_ICU_FUNCTIONS)
#else // RKL_APPEND_TO_ICU_FUNCTIONS
#define RKL_ICU_FUNCTION_APPEND(x) x
#endif // RKL_APPEND_TO_ICU_FUNCTIONS
或者:
#ifdef __OBJC__
#import <Foundation/Foundation.h>
#endif
使用此链接了解更多信息
要测试你是否运行iPad,你应该有这样的smth:
#define USING_IPAD UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad
if (USING_IPAD) {
NSLog(@"running iPad");
}
下面是另一个有用的预处理器函数:
#ifdef DEBUG
//here we run application through xcode (either simulator or device). You usually place some test code here (e.g. hardcoded login-passwords)
#else
//this is a real application downloaded from appStore
#endif