Search code examples
objective-cnsstringnslog

NSlog() to NSString


I want to take an NSLog() message and save it as a NSString.

For example, the following prints something like "Player coordinates (0,0)"

NSLog(@"Player cordinates(%i, %i)", xcord, ycord);

I want to save it's output (aka "Player coordinates (0,0)") into an NSString.


Solution

  • It can be done like that:

    NSString *yourString = [NSString stringWithFormat:@"Player cordinates(%i, %i)", xcord, ycord];