Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NSLog without new line

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

like image 349
philip Avatar asked Jul 14 '10 09:07

philip


2 Answers

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

like image 68
tato Avatar answered Oct 05 '22 10:10

tato


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.

like image 24
Macmade Avatar answered Oct 05 '22 08:10

Macmade