zoukankan      html  css  js  c++  java
  • 用NSLog记录Log的代码

    在XCode中 点 Run->Console可以查看NSLog的记录。

    NSLog(@"log: %@ ", myString);
    NSLog(@"log: %f ", myFloat);
    NSLog(@"log: %i ", myInt);




    NSLog() 寫到文件   

    - (void) redirectConsoleLogToDocumentFolder {

    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *documentsDirectory = [paths objectAtIndex:0];
    NSString *logPath = [documentsDirectory stringByAppendingPathComponent:@"console_log.txt"];
    freopen([logPath cStringUsingEncoding:NSASCIIStringEncoding],"a+",stderr);
    }

    // 用得時候
    - (void)applicationDidFinishLaunching:(UIApplication *)application {

    [self redirectConsoleLogToDocumentFolder];
    }


    然後在Xcode Organizer裡邊取出來

  • 相关阅读:
    文件操作(IO 技术)
    异常
    面向对象进阶
    面向对象
    函数用法和底层分析
    控制语句
    集合
    字典
    元组 tuple
    Python3 列表
  • 原文地址:https://www.cnblogs.com/shuaixf/p/2361348.html
Copyright © 2011-2022 走看看