IOS有用的宏

作者: koula | 来源:发表于2016-11-18 16:48 被阅读57次

    IOS有用的宏

    debug

    #ifdef __DEBUG__
    #define NSLog(format, ...) do {                                             \
    fprintf(stderr, "<%s : %d> %s\n",                                           \
    [[[NSString stringWithUTF8String:__FILE__] lastPathComponent] UTF8String],  \
    __LINE__, __func__);                                                        \
    (NSLog)((format), ##__VA_ARGS__);                                           \
    fprintf(stderr, "------------------------\n");                              \
    } while (0)
    #else
    #define NSLog(format, ...)
    #endif 
    

    Log Rect

    #define NSLogRect(rect) NSLog(@"%s x:%.4f, y:%.4f, w:%.4f, h:%.4f", #rect, rect.origin.x, rect.origin.y, rect.size.width, rect.size.height)
    #define NSLogSize(size) NSLog(@"%s w:%.4f, h:%.4f", #size, size.width, size.height)
    #define NSLogPoint(point) NSLog(@"%s x:%.4f, y:%.4f", #point, point.x, point.y)
    

    相关文章

      网友评论

        本文标题:IOS有用的宏

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