NSString* name = @"abc";
NSLog(name,nil);
who can tell me ,why add a nil? thank you very much.
The signature of NSLog
is void NSLog (NSString *format, ...);
.
So the first argument is rather a format instead of a literal string. The second (and all following) arguments are the substitution values for the format string.
You should not replace the format string with the string you want to log. If your string contains format specifiers like %d
NSLog
will try to replace them but will fail to do so as you have not entered a substitution.
You should always log with NSLog(@"%@", string)
when you want to log string
.