I need to use something like NSLog
but without the timestamp and newline character, so I'm using printf
. How can I use this with NSString
?
NSLog outputs the date, time, process name, process ID, and thread ID in addition to the log message. printf just outputs the message. NSLog requires an NSString and automatically adds a newline at the end. printf requires a C string and does not automatically add a newline.
A static, plain-text Unicode string object that bridges to String ; use NSString when you need reference semantics or other Foundation-specific behavior.
If you create an object using a method that begins with init, new, copy, or mutableCopy, then you own that object and are responsible for releasing it (or autoreleasing it) when you're done with it. If you create an object using any other method, that object is autoreleased, and you don't need to release it.
You can convert an NSString
into a UTF8
string by calling the UTF8String
method:
printf("%s", [string UTF8String]);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With