PDA

View Full Version : NSLog question




blue-lion
Jan 18, 2011, 12:20 PM
Hello, i believe the NSLog statement starts a new line each time it is used(like \n) . is there a way to prevent this? i.e. so multiple print statements appear back to back?

p.s. i don't just mean comma delimited either.



PhoneyDeveloper
Jan 18, 2011, 12:59 PM
I'm pretty sure there's no way to do that.

You can use printf() or the related functions for this.

Also, you can build up a single string with all the text that you want and then print it in a single call to NSLog.

blue-lion
Jan 18, 2011, 01:12 PM
Yes, i was thinking of combining strings using append....
Basically , i would like to neatly print playing card descriptions across the screen in columns of threes and left justified

Ace of clubs 4 of diamonds 6 of hearts
5 of diamonds

and so on...

i have tried using something like
NSLog(@"%-15s",[[tempCard CardDesc ] UTF8String]);

but i would like to link these together in threes, plus i don't really understand the syntax of these special strings???

PhoneyDeveloper
Jan 18, 2011, 02:12 PM
By screen I guess you mean the debugger console.

I use printf quite a bit for this kind of logging because it doesn't end up the system console, unlike NSLog. I really don't need this kind of debugging info filling up my system console.