views:

55

answers:

2

If I'm doing mass operations inside objective C, and a lot happens in the console... I cannot see it all happen in windows.

Instead of adding the argument ">>WriteLog.log" what would the proper way to log the console inside of Objective C?

+7  A: 

NSLog is the normal way to log to the console in Objective-C

You can use it like:

NSLog(@"My log string");

or

NSLog(@"%@", someStringObject);
James Raybould
Thanks James: )
Kyle
+1  A: 

Agreed with James, NSLog is the first method I've ever used with Obj-C to log.

To expand on James' the NSLog requires a string object as it's first argument, with optional referenced variables as following arguments.

IE:

int someInteger = 5;
NSString *someString = @"STRING";
double someDouble = 2.34;

NSLog(@"This is an INT: %i, while this is a string: %@, while this is a double: %.2f",someInteger,someString,someDouble);

// Output: 2010-08-30 11:45:25.400 StackOverflow[380:a0f] This is an INT: 5, while this is a string: STRING, while this is a double: 2.34

To see where %@, %i, %.2f come from, study string format specifiers.

Richard