国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學(xué)院 > 開發(fā)設(shè)計(jì) > 正文

ios開發(fā)--常用宏定義(部分轉(zhuǎn))

2019-11-14 19:20:28
字體:
供稿:網(wǎng)友

1、release時,屏蔽log

C代碼 復(fù)制代碼 收藏代碼
  1. #if defined (DEBUG) && DEBUG == 1  
  2.   
  3. #else  
  4. #define NSLog(...) {};  
  5. #endif  
#if defined (DEBUG) && DEBUG == 1#else#define NSLog(...) {};#endif

 

2、在主線程或在后臺執(zhí)行block

C代碼 復(fù)制代碼 收藏代碼
  1. #define BACK(block) dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), block)  
  2. #define MAIN(block) dispatch_async(dispatch_get_main_queue(),block)  
#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、設(shè)備相關(guān)

 

C代碼 復(fù)制代碼 收藏代碼
  1. #define isRetina ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(640, 960), [[UIScreen mainScreen] currentMode].size) : NO)  
  2.   
  3. #define iphone5 ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(640, 1136), [[UIScreen mainScreen] currentMode].size) : NO)  
  4.   
  5. #define isPad (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)  
  6.   
  7. #define CurrentSystemVersion ([[UIDevice currentDevice] systemVersion])  
  8.   
  9. #define CurrentLanguage ([[NSLocale preferredLanguages] objectAtIndex:0])   
#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、區(qū)分模擬器和真機(jī)

C代碼 復(fù)制代碼 收藏代碼
  1. #if TARGET_OS_IPHONE  
  2. //iPhone Device  
  3. #endif  
  4.   
  5. #if TARGET_IPHONE_SIMULATOR  
  6. //iPhone Simulator  
  7. #endif  
#if TARGET_OS_IPHONE//iPhone Device#endif#if TARGET_IPHONE_SIMULATOR//iPhone Simulator#endif

 

5、根據(jù)是否使用ARC做不同操作

C代碼 復(fù)制代碼 收藏代碼
  1. #if __has_feature(objc_arc)  
  2.     //compiling with ARC  
  3. #else  
  4.     // compiling without ARC  
  5. #endif  

發(fā)表評論 共有條評論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 灵山县| 广饶县| 内丘县| 泾川县| 梁平县| 永新县| 瑞昌市| 白沙| 瑞昌市| 遂溪县| 五大连池市| 通州区| 怀宁县| 黄大仙区| 通化市| 阿荣旗| 齐齐哈尔市| 农安县| 阿城市| 祁连县| 比如县| 鄱阳县| 略阳县| 衡阳市| 承德市| 嘉义市| 达日县| 迁安市| 颍上县| 北宁市| 临桂县| 连州市| 汝阳县| 临潭县| 西宁市| 句容市| 福贡县| 萝北县| 福建省| 云安县| 阳西县|