CGFloat value = 0.333333;
NSLog(@"%.2f%%",value*100);
Will result in 33.33%
in the log.
Here is the relevant section from Apple's docs. The Objective-C format specifiers very closely follow (or might even be the same as) those you might know from C. NSLog()
automatically accepts format specifiers. To do this with any NSString
, use [NSString stringWithFormat:@"myString", arg1, arg2..]
.