tags:

views:

88

answers:

3

Hi,

I am simply logging a number using a for-loop.

for (i=0; i<6; i++)
{

    NSLog(@"%d",i);
}

It prints the number in new line like:

1

2

3

4

5

But I want to see it formatted on one line like 12345. How can I do this, any idea?

thanks Aaryan

+1  A: 

printf("%d",i) is what you need

ennuikiller
+5  A: 

NSLog() is for logging purposes, not general printing. You want printf().

printf("%d", i);

will print the number without any extraneous info or newlines added.

Chuck
+1  A: 

You could build up your own string and then output one NSLog at the end:

NSMutableString *logString = [NSMutableString stringWithCapacity:100];
for (i=0; i<6; i++) {
   [logString appendFormat:@"%d" i]
}
NSLog(@"%@", logString); 
Epsilon Prime