• ios 项目里常用的宏


    NSLog(@"__func__ :  %s", __func__);//oc测试环境,打印文件名,方法名

    NSLog(@"__FUNCTION__ : %s", __FUNCTION__);//同上

    NSLog(@"__PRETTY_FUNCTION__ : %s", __PRETTY_FUNCTION__);//同上

    NSLog(@"__FILE__ : %s", __FILE__);//打印文件路径

    NSLog(@"__LINE : %d", __LINE__);//打印行号

    在项目里.pch 文件最后加入我们想要定义的宏就可以了,在整个项目中我们都可以使用这些宏。

    #pragma mark - safe release

    /*

     * 释放内存

     */

    #define RELEASE(_Ptr)

    if (_Ptr)

    {

    [_Ptr release];

    _Ptr = nil;

    }

     

     

    #pragma mark -  width and height

    /*

     * 屏幕尺寸,APP尺寸

     */

    #define SCREEEN_WIDTH [UIScreen mainScreen].bounds.size.width

    #define SCREEEN_HEIGHT [UIScreen mainScreen].bounds.size.height

    #define APPFRAME_WIDTH  [UIScreen mainScreen].applicationFrame.size.width

    #define APPFRAME_HEIGHT  [UIScreen mainScreen].applicationFrame.size.height

     

     

    #pragma mark -  iPhone or iPad

    /*

     * 是否是iPhoneiPad

     */

    #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)

     

     

    #pragma mark -  ios system

    /*

     * 系统版本,偏好语言

     */

    #define IOS_VERSION [[UIDevice currentDevice].systemVersion floatValue]

    #define PREFERRED_LANGUAGE  ([[NSLocale preferredLanguages] objectAtIndex:0])

     

    #pragma mark - color functions

    /*

     * 颜色运算

     */

    #define RGBCOLOR(r,g,b) [UIColor colorWithRed:(r)/255.0f green:(g)/255.0f blue:(b)/255.0f alpha:1];

    #define RGBACOLOR(r,g,b,a) [UIColor colorWithRed:(r)/255.0f green:(g)/255.0f blue:(b)/255.0f alpha:(a)];

     

     

    #pragma mark -  nsnotification

    /*

     * 订阅/取消消息通知

     */

    #define Add_Notification(selectorName, notificationName) [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(selectorName) name:notificationName object:nil];

    #define Remove_Notification(notificationName) [[NSNotificationCenter defaultCenter] removeObserver:self name:notificationName object:nil];

     

     

     

    #pragma mark - debug

    /*

     * 打印debug信息

     */

    //use dlog to print while in debug model

    #ifdef DEBUG

    #   define DLog(fmt, ...) NSLog((@"%s [Line %d] " fmt), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__);

    #else

    #   define DLog(...)

    #endif

     

     

     

    #pragma mark - ARC

    /*

     *是否使用了ARC

     */

    #if __has_feature(objc_arc)

    //compiling with ARC

    #else

    // compiling without ARC

    #endif

     

     

    #pragma mark - GCD

    /*

     *GCD

     */

    #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)

  • 相关阅读:
    Oracle中job的使用详解
    Control File (二)重建CONTROLFILE --- NORESETLOG
    Oracle Analyze 命令 详解
    深入学习Oracle分区表及分区索引
    B树索引和位图索引的区别!
    RAID0_RAID1_RAID10_RAID5各需几块盘才可组建
    Oracle IO优化心得
    修改dbwr后台进程数量
    查看ORACLE执行计划的几种常用方法
    printf()格式化输出详解及echo带颜色输出
  • 原文地址:https://www.cnblogs.com/shidaying/p/3597719.html
Copyright © 2020-2023  润新知