I need help. How come this does not work:
NSProcessInfo *process = [NSProcessInfo processInfo];
NSString *processName = [process processName];
int processId = [process processIdentifier];
NSString *processString = [NSString stringWithFormat:@"Process Name: @% Process ID: %f", processName, processId];
NSLog(processString);
But this does:
NSLog(@"Process Name: %@ Process ID: %d", [[NSProcessInfo processInfo] processName], [[NSProcessInfo processInfo] processIdentifier]);
%@
: Output the string form of an object (including NSString
).%f
: Output a floating point number (float
)%d
: Output an integral number (int
)%x
: Output hexadecimal form of a numberYour original NSString:stringWithFormat:
had two issues:
@%
should be %@
to output an NSString.%f
instead of %d
to output an int.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