Amazon.com Widgets Exercise #6...
Welcome, Guest. Please login or register.
Did you miss your activation email?
October 25, 2014, 06:20:40 AM
Home Help Search chat Login Register 
News: Read this please.The Great Kangaroo Escape Looking for reviews of the 4th ed on Amazon!   Twitter:  @skochan
                     

+ Official Forum for Programming in Objective-C (the iPhone Programming Language) - Stephen Kochan
|-+ Programming in Objective-C, 4th edition
| |-+ Chapter 2
| | |-+ Exercise #6...
Pages: [1] Go Down
Print
Author Topic: Exercise #6... (Read 1963 times)
integr8d
Newbie
*
Posts: 4






on: March 09, 2012, 03:35:36 PM

The NSLog format string ends with \n. Just curious as to why:Smiley

Logged
adronh
Newbie
*
Posts: 2


Email




Reply #1 on: March 15, 2012, 08:58:21 PM

NSLog (@"The result is %i\n", result + 5);

I think the \n was intended to be before the %i, which would have put the answer 95 on the next line.  Otherwise I don't see any need for it. 
Logged
EthanChu
Newbie
*
Posts: 5


Email




Reply #2 on: February 01, 2013, 07:50:03 AM

In general, I prefer change it
NSLog (@"The result is %i\n", result + 5); with

NSLog (@"\n The result is %i", result + 5);  -> it look good!
Logged
Coda50
Newbie
*
Posts: 16


Email




Reply #3 on: February 22, 2013, 10:24:34 AM

I hope this answers your question.  The '\n' is a newline character. The only thing it say is, "Start a new line after you print what's before me". 
Logged
afterDark
Global Moderator
Full Member
*****
Posts: 131






Reply #4 on: February 22, 2013, 11:16:20 AM

Note that NSLog always puts a newline after its output (in contrast to printf() ) also without any \n at the end. Funnily enough if you put a \n at the end of an NSLog, there is not an second newline printed. There is, however, an second newline if you add two \n's at the end of NSLog.
Logged

I am just an amateur with Objective-C, don't let the moderator label fool you. Working my way through the book slowly.
Pages: [1] Go Up
Print
Jump to:



Login with username, password and session length

Powered by MySQL Powered by PHP Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC Valid XHTML 1.0! Valid CSS!
Entire forum contents (c) 2009 classroomM.com. All rights reserved.