Why is my xcode 4.2 log always empty?

…衆ロ難τιáo~ 提交于 2019-12-01 13:07:32

问题


in a method that is accessed three times I want to write something to the log.

NSLog(@"%@", [response responseString]);

But there is nothing in the log. The log windows is completely white. Normally when I start an application there is always some stuff that shows up in the log but now it is totally empty.

How can I fix this?


回答1:


Perhaps a really silly thing, but in the top right-corner of the console you should see this:

Check that the middle segment or right segment is selected.




回答2:


NSString *responseString = [response responseString];
NSLog(@"%@", responseString);

set a breakpoint on the first line and debug the application to see if its coming in this code in the first place. If it is, hover over responseString and it will tell you whether it is nil or not.




回答3:


When Console isn't behaving nicely for me (which happens sometimes when I'm doing driver level stuff or multi-threaded apps), a much more reliable thing to do is something like:

- (void) printToLog: (NSString *) aFormattedStringToPrint
{
    // don't forget to remove an older copy of this file before 
    // your app finishes launching
    FILE * aFile = fopen( "/tmp/debuggingoutput.txt", "a");
    if(aFile)
    {
         fprintf(aFile, "%s", [aFormattedStringToPrint UTF8String];
         fflush(aFile);
         fclose(aFile);
    }
}

(you can define a macro like LOGTHIS which might toggle between NSLog and the above more direct and to the point code)

And then you can "tail -f /tmp/debuggingoutput.txt" in your Terminal window while debugging and if nothing appears there, then you know your debugging lines aren't getting hit.




回答4:


Today I have been frustrated with a similar problem. When the console is activated, only the variables pane is showing. No sign of the console pane. After finding Debug Area Help via right clicking in the variable pane, i could see that it is meant to sit next to it on the right.

The key for me was to Hide the Utilities panel. For me, the little buttons shown in Luke's answer above would not appear until hiding and unhiding the Utilites panel.



来源:https://stackoverflow.com/questions/7849181/why-is-my-xcode-4-2-log-always-empty

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!