Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

danmwall

macrumors newbie
Original poster
Apr 13, 2009
17
0
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...
 

CocoaPuffs

macrumors 68020
Aug 23, 2008
2,005
3
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...
set the number of lines to be shown in label attribute, and then use \n as line breaker.
 

danmwall

macrumors newbie
Original poster
Apr 13, 2009
17
0
Duh! Of course! You would think I would have tried that! Thanks, it works like a charm!
 

Guiyon

macrumors 6502a
Mar 19, 2008
771
4
Cambridge, MA
[sampleText setText:mad:"This text is pretty long. I would like a CRLF here. See, isn't this easier to read now?"];

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).
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.