美文网首页
iOS 输出格式

iOS 输出格式

作者: 冰点雨 | 来源:发表于2020-08-13 09:33 被阅读0次
    - (void)viewDidLoad {
        [super viewDidLoad];
        // Do any additional setup after loading the view.
         
        /*
               %@           OC对象
         
               %d        整型
         
               %hd          短整型
         
               %ld,%lld     长整型
         
               %u           无符整型
         
               %f           浮点型和double型
         
               %0.2f        精度浮点数,只保留两位小数
               
               %x, %X 二进制整数
         
               %x:       为32位的无符号整型数(unsigned int),打印使用数字0-9的十六进制,小写a-f;
         
              %X:       为32位的无符号整型数(unsigned int),打印使用数字0-9的十六进制,大写A-F;
         
               %o            八进制
         
               %zu/%zd       size_t/NSInteger
         
               %p            指针地址
         
               %e            float/double(科学计数)
         
               %g            float/double(科学计数)
         
               %s            char *  字符串
         
               %.*s          Pascal字符串
         
               %c            char 字符
         
               %C            unichar
         
               %Lf           64位double
         
               %lu           sizeof(i)内存中所占字节数
         
               NSStringFromCGAffineTransform()
               NSStringFromCGPoint()
               NSStringFromCGRect()
               NSStringFromCGSize()
               NSStringFromCGVector()
               NSStringFromClass()
               NSStringFromProtocol()
               NSStringFromRange()
               NSStringFromSelector() //sel_getName()也可以
               NSStringFromUIEdgeInsets()
               NSStringFromUIOffset()
         
          */
     
              /** 几种不同的打印函数 **
              NSLog(<#NSString * _Nonnull format, ...#>)     --> OC
              printf(<#const char *restrict, ...#>)          --> C
              CFShow(<#CFTypeRef obj#>)                      --> Core Foundation
              CFShowStr(<#CFStringRef str#>)                 --> Core Foundation
               */
    
              NSLog(@"当前方法名:%@",NSStringFromSelector(_cmd));
              NSLog(@"当前方法名: %s",sel_getName(_cmd));
              NSLog(@"[类 方法]:%s",__func__);
              NSLog(@"[类 方法]:%s",__FUNCTION__);
              NSLog(@"当前类名:%@",NSStringFromClass([self class]));
              NSLog(@"当前行号:%d",__LINE__);
         
              NSLog(@"当前文件存储路径:%s",__FILE__);
              NSString *pathStr = [NSString stringWithCString:__FILE__ encoding:NSUTF8StringEncoding]; //将CString -> NSString
              NSLog(@"当前文件名:%@",[pathStr lastPathComponent]);
    
              NSLog(@"当前日期:%s",__DATE__);
              NSLog(@"当前时间:%s",__TIME__);
              NSLog(@"当前App运行要求的最低ios版本:%d",__IPHONE_OS_VERSION_MIN_REQUIRED);  //Develop Target: 已选8.0
             NSLog(@"当前App支持的最高ios版本:%d",__IPHONE_OS_VERSION_MAX_ALLOWED);    //Develop Target: 最高9.0
             NSLog(@"打印__IPHONE_13_0:%d",__IPHONE_13_0);  //打印ios7.0
        
             NSLog(@"当前线程:%@",[NSThread currentThread]);
             NSLog(@"主线程:%@",[NSThread mainThread]);
             NSLog(@"当前栈信息:%@", [NSThread callStackSymbols]);
        
    
             //SEL对象即一个@selector对象,保存一个方法的地址
             SEL sel0 = _cmd; //代表当前方法
             SEL sel1 = @selector(sayHello);//将sayHello方法包装成SEL对象
             SEL sel2 = NSSelectorFromString(@"sayHello"); //从方法名字符串创建SEL对象
             [self sayHello];
             [self performSelector:sel1];
             [self performSelector:sel2 withObject:@"123"];
    }
    
    
    - (void)sayHello {
    
         NSLog(@"Hello, world!");
     }
    

    打印输出

    2020-08-13 09:32:14.682194+0800 SSGestureLockView[64607:10857160] 当前方法名:viewDidLoad
    2020-08-13 09:32:14.682653+0800 SSGestureLockView[64607:10857160] 当前方法名: viewDidLoad
    2020-08-13 09:32:14.682785+0800 SSGestureLockView[64607:10857160] [类 方法]:-[AdvertDeatilViewController viewDidLoad]
    2020-08-13 09:32:14.682907+0800 SSGestureLockView[64607:10857160] [类 方法]:-[AdvertDeatilViewController viewDidLoad]
    2020-08-13 09:32:14.683047+0800 SSGestureLockView[64607:10857160] 当前类名:AdvertDeatilViewController
    2020-08-13 09:32:14.683169+0800 SSGestureLockView[64607:10857160] 当前行号:90
    2020-08-13 09:32:14.683286+0800 SSGestureLockView[64607:10857160] 当前文件存储路径:/Users/ios001/Documents/demo/SSGestureLockView/SSGestureLockView/class/my/AdvertDeatilViewController.m
    2020-08-13 09:32:14.683538+0800 SSGestureLockView[64607:10857160] 当前文件名:AdvertDeatilViewController.m
    2020-08-13 09:32:14.683688+0800 SSGestureLockView[64607:10857160] 当前日期:Aug 13 2020
    2020-08-13 09:32:14.683816+0800 SSGestureLockView[64607:10857160] 当前时间:09:31:54
    2020-08-13 09:32:14.683934+0800 SSGestureLockView[64607:10857160] 当前App运行要求的最低ios版本:110400
    2020-08-13 09:32:14.684052+0800 SSGestureLockView[64607:10857160] 当前App支持的最高ios版本:130000
    2020-08-13 09:32:14.684161+0800 SSGestureLockView[64607:10857160] 打印__IPHONE_13_0:130000
    2020-08-13 09:32:14.684453+0800 SSGestureLockView[64607:10857160] 当前线程:<NSThread: 0x280c46e80>{number = 1, name = main}
    2020-08-13 09:32:14.684669+0800 SSGestureLockView[64607:10857160] 主线程:<NSThread: 0x280c46e80>{number = 1, name = main}
    2020-08-13 09:32:14.692090+0800 SSGestureLockView[64607:10857160] 当前栈信息:(
        0   SSGestureLockView                   0x00000001025fcb84 -[AdvertDeatilViewController viewDidLoad] + 808
        1   UIKitCore                           0x00000001bcc50bb4 <redacted> + 1028
        2   UIKitCore                           0x00000001bcc50fc0 <redacted> + 32
        3   UIKitCore                           0x00000001bcbaa310 <redacted> + 1076
        4   UIKitCore                           0x00000001bcbbea70 <redacted> + 712
        5   UIKitCore                           0x00000001bcbbfedc <redacted> + 168
        6   UIKitCore                           0x00000001bcba25bc <redacted> + 228
        7   UIKitCore                           0x00000001bd6d70a0 <redacted> + 1308
        8   libobjc.A.dylib                     0x000000018effb454 <redacted> + 68
        9   QuartzCore                          0x00000001943d3db4 <redacted> + 188
        10  QuartzCore                          0x00000001943d40a0 <redacted> + 336
        11  QuartzCore                          0x000000019433b17c <redacted> + 344
        12  QuartzCore                          0x0000
    2020-08-13 09:32:14.693746+0800 SSGestureLockView[64607:10857160] Hello, world!
    2020-08-13 09:32:14.693922+0800 SSGestureLockView[64607:10857160] Hello, world!
    2020-08-13 09:32:14.694013+0800 SSGestureLockView[64607:10857160] Hello, world!
    

    相关文章

      网友评论

          本文标题:iOS 输出格式

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