[ACCEPTED]-What is the syntax for new line in Objective-C?-objective-c
Objective-C is an extension of C. So '\n' works 1 too in Objective-C.
It's the same (
\n), but there's a lot more 39 to the topic depending on whether it's just 38 a new line or a new paragraph, what context the text 37 will be processed in, etc. From the documentation (referencing 36 the Cocoa docs here because they cover both 35 Objective-C [implicitly] and Cocoa, since 34 you have the
iphone tag on your question):
There 33 are a number of ways in which a line or 32 paragraph break may be represented. Historically 31
\r\nhave been used. Unicode defines 30 an unambiguous paragraph separator,
U+2029(for 29 which Cocoa provides the constant
NSParagraphSeparatorCharacter), and 28 an unambiguous line separator,
U+2028(for which 27 Cocoa provides the constant
In the Cocoa 26 text system, the
NSParagraphSeparatorCharacteris treated consistently 25 as a paragraph break, and
NSLineSeparatorCharacteris treated consistently 24 as a line break that is not a paragraph 23 break—that is, a line break within a paragraph. However, in 22 other contexts, there are few guarantees 21 as to how these characters will be treated. POSIX-level 20 software, for example, often recognizes 19 only
\nas a break. Some older Macintosh software 18 recognizes only
\r, and some Windows software 17 recognizes only
\r\n. Often there is no distinction 16 between line and paragraph breaks.
Which 15 line or paragraph break character you should 14 use depends on how your data may be used 13 and on what platforms. The Cocoa text system 12 recognizes
\r\nall as paragraph breaks—equivalent 11 to
NSParagraphSeparatorCharacter. When it inserts paragraph breaks, for 10 example with
insertNewline:, it uses
NSLineSeparatorCharacteris 9 used only for breaks that are specifically 8 line breaks and not paragraph breaks, for 7 example in
insertLineBreak:, or for representing HTML
If 6 your breaks are specifically intended as 5 line breaks and not paragraph breaks, then 4 you should typically use
NSLineSeparatorCharacter. Otherwise, you 3 may use
\r\ndepending on what other 2 software is likely to process your text. The 1 default choice for Cocoa is usually
It's the same, but if you are printing to 1 the console, you should use
NSLog(@"This is a console statement\n on two different lines");
Hope this helps.
It's same dude. Objective-c is superset 2 of c so most of the things from c will work 1 in objective-c too.
Its same.In Objective c "\n" use for new 1 line.
Straight from the dragons mouth. http://developer.apple.com/library/mac/#documentation/cocoa/conceptual/Strings/Articles/stringsParagraphBreaks.html
More Related questions