zoukankan      html  css  js  c++  java
  • 字符串相互转换打印

    1.在非调试状态下NSLog不工作

    #ifdef DEBUG
    #define NSLog(...) NSLog(__VA_ARGS__)
    #else
    #define NSLog(...)
    #endif

    2.去掉打印的时间戳

    #ifdef DEBUG
    #define NSLog(FORMAT, ...) fprintf(stderr,"%s
    ",[[NSString stringWithFormat:FORMAT, ##__VA_ARGS__] UTF8String]);
    #else
    #define NSLog(...)
    #endif

    3.不同颜色的打印

    #ifdef DEBUG
    #define NSLog(FORMAT, ...) fprintf(stderr,"%s:%d	%s
    ",[[[NSString stringWithUTF8String:__FILE__] lastPathComponent] UTF8String], __LINE__, [[NSString stringWithFormat:FORMAT, ##__VA_ARGS__] UTF8String]);
    #else
    #define NSLog(...)
    #endif

    4.unicode转换成中文

    #define NSLog(format, ...) NSLog(format, ## __VA_ARGS__)

    5.结构体转化为字符串打印

        CGRect rect = CGRectMake(0.0, 0.0, 320.0, 460.0);
    
        NSString *str = NSStringFromCGRect(rect); //结构体转化为字符串
    
        NSLog(@"%@",str);
    
        //CGRectFromString(str); //字符串转化为结构体
  • 相关阅读:
    一分钟 解决Tomcat端口 占用问题
    Java 自定义注解
    Java 解析自定义XML文件
    Junit(手动/自动)加载
    Java思维题
    SSM框架中使用日志框架
    DAC
    SPI接口的FLASH
    晶振测试起振方法
    Jlink不报错的方法
  • 原文地址:https://www.cnblogs.com/shen5214444887/p/4826518.html
Copyright © 2011-2022 走看看