How can I add a CRLF to a label?

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

  1. danmwall macrumors newbie

    Apr 13, 2009
    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. CocoaPuffs macrumors 68010

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

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

    Mar 19, 2008
    North Shore, MA
    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