I know how to format a float when displaying it as part of an NSString (see e.g. Make a float only show two decimal places) but is there a way to dynamically set the number of decimal digits to be displayed? For example, if I know I want int dig digits can I modify the following expression to format my float as desired?
NSString* formattedNumber = [NSString stringWithFormat:@"%.02f", myFloat];
I know I can do this with NSNumberFormatter, but I'm looking for a more direct method.