Objective C General Print
Does objective C have a general print command like Python? NSLog seems to log it开发者_StackOverflow中文版 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]]);
加载中,请稍侯......
精彩评论