Logging to a file on the iPhone

后端 未结 5 1609
暗喜
暗喜 2020-11-30 20:45

What would be the best way to write log statements to a file or database in an iPhone application?

Ideally, NSLog() output could be redirected to a file using freop

5条回答
  •  醉酒成梦
    2020-11-30 21:21

    This code works for me:

    - (void)applicationDidFinishLaunching:(UIApplication *)application {
    #if TARGET_IPHONE_SIMULATOR == 0
        freopen([@"/tmp/my_logs.txt" fileSystemRepresentation], "w", stderr);
    #endif
    }
    

提交回复
热议问题