I have see this in sample objective c code before, but can't find it now and all the searches come back with irrelivent results.
I want to write debug messages to the Xcode output window. What's the command to do that? Basically like System.Diagnostics.Debug.WriteLine for C#.
If you just want to have the log output display when you run your app then you can go into XCode4 preferences -> Alerts and click on 'Run starts' on the left hand column. Then select 'Show Debugger' and when you run the app the NSLog output will be displayed below the editor pane.
Click the Add Action button and select Debugger Command. Put any print command in a debug console in a text field. Make sure you prefix it with po , e.g., po print(view) . Check Automatically continue after evaluating actions.
To see the debug output window, in Microsoft Visual Studio, click View, click Other Windows, and then click Output. You can view the debug output in this window only if the debugger is attached to the process that is writing to the output window.
NSLog outputs messages to the Apple System Log facility or to the Console app (usually prefixed with the time and the process id).
NSLog(@"Your message here");
...should do it.
To include data from variables you can use string formatting, e.g:
NSLog(@"Value of string is %@", myNSString);
There are a bunch of different string format specifiers, you can look at them here: https://developer.apple.com/library/content/documentation/Cocoa/Conceptual/Strings/Articles/formatSpecifiers.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With