1、release时,屏蔽log
C代码 class="star" src="/Upload/Images/2015033115/40B102E0EF997EA6.png" alt="收藏代码" />spinner" style="display: none;" src="/Upload/Images/2015033115/4E072B8B8C20032D.gif" alt="" />#if defined (DEBUG) && DEBUG == 1 #else #define NSLog(...) {}; #endif
2、在主线程或在后台执行block
C代码#define BACK(block) dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), block) #define MAIN(block) dispatch_async(dispatch_get_main_queue(),block)
3、设备相关
C代码
#define isRetina ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(640, 960), [[UIScreen mainScreen] currentMode].size) : NO) #define iPhone5 ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(640, 1136), [[UIScreen mainScreen] currentMode].size) : NO) #define isPad (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) #define CurrentSystemVersion ([[UIDevice currentDevice] systemVersion]) #define CurrentLanguage ([[NSLocale preferredLanguages] objectAtIndex:0])
4、区分模拟器和真机
C代码#if TARGET_OS_IPHONE //iPhone Device #endif #if TARGET_IPHONE_SIMULATOR //iPhone Simulator #endif
5、根据是否使用ARC做不同操作
C代码