Write debug messages to Xcode output window Write debug messages to Xcode output window ios ios

Write debug messages to Xcode output window


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


You are looking for NSLog. Calling

NSLog(@"Message");

will print Message on the console.

See here for more info about how to use string formatters to print the values of variables like in the examples below:

NSLog(@"This is a string: @", aString);NSLog(@"This is an int: %d", anInt);


It's better to write the debug messages using debugger breakpoints instead of cluttering your code with NSLog messages. Breakpoints will also save you from having to remove all those log messages when you ship your app.

To do this, set a breakpoint in Xcode, double-click on it, and click the Add Action button in the pop-up window. Select "Log Message" and type your message. Check the "Automatically continue after evaluating" check box at the bottom to keep it from pausing execution on the breakpoint


matomo