Does objective C have a general print command like Python? NSLog seems to log it rather than print out to console. printf only accepts specific types.
NSLog()
does print to the console, and is very similar to C's printf()
. Having its origins and basis in C, console printing is done as it is in C, essentially.
printf
is what you're looking for. You can use it like a regular print statement:
printf("This is a neat command!\n");
You're also probably aware that you can use it with substitutions:
printf("The Answer is %d\n", 42);
You can use NSString
to format strings containing id types as well as the standard printf types, then just print it using printf:
NSString *fmt = [NSString stringWithFormat:@"My formatted string: %@", anObject];
printf("%s", [fmt cStringUsingEncoding:[NSString defaultCStringEncoding]]);
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