NSLog question

Discussion in 'iOS Programming' started by blue-lion, Jan 18, 2011.

  1. macrumors member

    Jan 26, 2010
    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.
  2. macrumors 68030


    Sep 2, 2008
    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.
  3. blue-lion, Jan 18, 2011
    Last edited: Jan 18, 2011

    thread starter macrumors member

    Jan 26, 2010

    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???
  4. macrumors 68030


    Sep 2, 2008
    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.

Share This Page