What's the best way to log debug info in an iphone app?

后端 未结 5 1641
执笔经年
执笔经年 2021-02-05 18:26

Is there some standard way or has anyone written something that allows you to log a message and have it be displayed either in a small scrolling section on the iphone screen or

5条回答
  •  日久生厌
    2021-02-05 19:15

    I don't have enough 'reputation' to add a direct comment for your posting but: don't forget to go to XCode->Preferences->Debugging->On Start: Choose Show Console & Debugger

    You can of course choose just the Console or whatever, but you'll probably want the Debugger to. To use that, just click to the left of the line you want to break at. You can also toggle from 'Activate' to 'Deactivate' so you if you know that there are a bunch of breakpoints you don't need to hit in the beginning of your application set the debugging to Deactive (in the debugging window) and then, before you hit the UI element in your app you want to debug, toggle that same button to Activate so your breakpoints become active. Otherwise, you could of course just click Continue until you got to your section.

    Also, on the NSLog, if you start to accumulate a bunch of log statements, and you need to 'find' one in particular, it helps to do: NSLog(@"\n\n\nMy statement\n\n\n); which will give a bunch of line breaks. Also, for the uninitiated:

    NSLog(@"My int: %d my BOOL: %d", myInt, myBOOL);
    NSLog(@"My object of any NSObject: %@", anObjectOfAnyKind);
    NSLog(@"My float: %f",myFloat);
    

    Hope all of this is helpful and sorry if I got off track with the debugging bit ;)

提交回复
热议问题