Quote:
Originally Posted by Glnn
I'm having trouble formatting a double to a string..
This is the code is use..
Code:
secondLabel.text = [NSString stringWithFormat:@"%i.%i", second, millisecond];
NSString *convert = [NSString stringWithFormat:@"%i.%i", second, millisecond];
kilometers = [convert doubleValue];
kilometers = kilometers * 2.9;
meterLabel.text = [NSString stringWithFormat:@"%d", kilometers];
and this is the result..
Anybody?
|
Couple things: (1) it's not clear from your post which snippet of code is responsible for the image that you posted, (2) "%d" is for integers and shouldn't result in a number with a decimal point, and (3) you haven't specified exactly what output you're looking to achieve.
Here's a link to some Apple documentation on string formatters:
String Programming Guide for Cocoa: String Format Specifiers.