美文网首页
iOS开发常用的宏

iOS开发常用的宏

作者: shuai1234 | 来源:发表于2016-09-02 16:04 被阅读16次

    1.debug模式和release模式的NSLog打印

    #ifdef DEBUG
    #define LRLog(...) NSLog(@"%s 第%d行 \n %@\n\n",__func__,__LINE__,[NSString stringWithFormat:__VA_ARGS__])
    #else
    #define LRLog(...)#endif
    

    2.弱引用/强引用

    #define YSWeakSelf(type) __weak typeof(type) weak##type = type;
    #define YSStrongSelf(type) __strong typeof(type) type = weak##type;
    

    3.判断真机还是模拟器

    #if TARGET_OS_IPHONE //iPhone Device 
    #endif 
    #if TARGET_IPHONE_SIMULATOR //iPhone Simulator 
    #endif
    

    4.沙盒目录文件

    //获取temp
    #define kPathTemp NSTemporaryDirectory()
    //获取沙盒 Document#define kPathDocument 
    [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) firstObject]
    //获取沙盒 Cache#define kPathCache 
    [NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES) firstObject]
    

    相关文章

      网友评论

          本文标题:iOS开发常用的宏

          本文链接:https://www.haomeiwen.com/subject/yltkettx.html