How can I add a CRLF to a label?

Discussion in 'iOS Programming' started by danmwall, Apr 18, 2009.

  1. macrumors newbie

    Joined:
    Apr 13, 2009
    #1
    I have a label that is set to wrap to multiple lines. I am setting the text in the code using setText, but it is rather long and I would like to break it up to make it easier to read. Is there a way to insert a carriage return/line feed? For example:

    [sampleText setText:mad:"This text is pretty long. I would like a CRLF here. See, isn't this easier to read now?"];

    Seems like it should be simple enough...
     
  2. macrumors 68010

    Joined:
    Aug 23, 2008
    #2
    set the number of lines to be shown in label attribute, and then use \n as line breaker.
     
  3. thread starter macrumors newbie

    Joined:
    Apr 13, 2009
    #3
    Duh! Of course! You would think I would have tried that! Thanks, it works like a charm!
     
  4. macrumors 6502a

    Joined:
    Mar 19, 2008
    Location:
    North Shore, MA
    #4
    Being nit-picky here but, simply for information's sake, using CRLF (\r\n) as a line/section break is limited mostly to ASCII-based comm protocols and Windows. The POSIX world (Mac OS X, Linux, *BSD, etc.) all use just an LF (\n) while Classic Mac OS used CR (\r).
     

Share This Page