Advertise Books Events Forum News Social Networking Support Us

sdkIQ for iPhone
($4.99)

Shape Up
($0.99)

Your First iPhone App
($1.99)

iVidCam Free
(free)

Kid Art
($0.99)

iPUBQUIZ
(£1.19)

ArtStudio
($3.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum

View Single Post
Old 07-10-2009, 03:43 PM   #2 (permalink)
Kalimba
Pro. Game Developer
iPhone Dev SDK Supporter
 
Join Date: Feb 2009
Location: ¿La Islas Hermosas?
Posts: 1,404
Default

Quote:
Originally Posted by Glnn View Post
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.
__________________
piña para la niña interactive
Kalimba is offline   Reply With Quote
 
Enter the iPhone App Challenge!  Win $500!
» Advertisements
» Stats
Members: 23,855
Threads: 38,628
Posts: 169,579
Top Poster: smasher (2,547)
Welcome to our newest member, laurelbigler58
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 07:05 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.