NSLog without new line
Asked Answered
H

3

8

Is there any function that does what NSLog does but without the new line at the end?

Hogback answered 14/7, 2010 at 9:4 Comment(0)
M
9

see this http://borkware.com/quickies/one?topic=NSString

excerpted from that page:

void LogIt (NSString *format, ...)
{
    va_list args;
    va_start (args, format);
    NSString *string;
    string = [[NSString alloc] initWithFormat: format  arguments: args];
    va_end (args);
    printf ("%s\n", [string UTF8String]);
    [string release];
} // LogIt

just customize the printf to suit your needs

Mylonite answered 17/8, 2010 at 14:49 Comment(1)
NSString cString is deprecated. Use NSString UTF8String instead.Dressage
S
4

You can use printf(), but the time won't be displayed, and you won't be able to use the "%@" sequence for objects.

That said, you can implement your own logging function, using printf(), and adding support for objects. You will need to know how to deal with C variable arguments.

Saucer answered 14/7, 2010 at 9:11 Comment(0)
M
1

you can use some trick. use special unicode character like:u00a0

NSLog(@"\n\n\n\u00a0")

Mcculley answered 27/4, 2021 at 6:50 Comment(1)
What does it do?Messy

© 2022 - 2024 — McMap. All rights reserved.