zoukankan      html  css  js  c++  java
  • ios开发--常用宏定义(部分转)

    1、release时,屏蔽log
     
    #if defined (DEBUG) && DEBUG == 1  
      
    #else  
    #define NSLog(...) {};  
    #endif  
     
    2、在主线程或在后台执行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、设备相关
     
    #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、区分模拟器和真机
    
    #if TARGET_OS_IPHONE  
    //iPhone Device  
    #endif  
      
    #if TARGET_IPHONE_SIMULATOR  
    //iPhone Simulator  
    #endif  
     
    5、根据是否使用ARC做不同操作
    
    #if __has_feature(objc_arc)  
        //compiling with ARC  
    #else  
        // compiling without ARC  
    #endif  

    转 http://apluck.iteye.com/blog/1768787

  • 相关阅读:
    学习进度(第十四周)
    学习进度(第十三周)
    程序员修炼之道阅读笔记03
    程序员修炼之道阅读笔记02
    学习进度(第十二周)
    冲刺进度条10
    冲刺进度条09
    冲刺进度条08
    寒假学习进度报告2
    寒假学习进度报告1
  • 原文地址:https://www.cnblogs.com/ygm900/p/3156386.html
Copyright © 2011-2022 走看看