Wie konvertieren von Typ double zu string-iPhone?

Bin ich der Berechnung der Geschwindigkeit eines iPhone, und ich muss wissen, wie konvertiert man die variable calculatedSpeed der Typ double in den Typ string zur Anzeige auf einem Etikett.

Hier ist was ich in den header:

@interface myProject : UIViewController <CLLocationManagerDelegate> {

double calculatedSpeed; 
    UILabel *velocityLabel;
}

Und hier ist, was ich in der main:

-(void)speedLocation:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation
{
double gpsSpeed = newLocation.speed;

if(oldLocation != nil)
{
    CLLocationDistance distanceChange = [newLocation getDistanceFrom:oldLocation];
    NSTimeInterval sinceLastUpdate = [newLocation.timestamp timeIntervalSinceDate:oldLocation.timestamp];
    calculatedSpeed = distanceChange / sinceLastUpdate;

    velocityLabel.text = calculatedSpeed;

}

}

Bemerken, wie ich bin, die versuchen, velocityLabel zu calculatedSpeed, die ist eine variable mit dem Typ "double". Also es gibt natürlich mir die Fehlermeldung: inkompatibler Typ für argument 1 von " setText:'.

Ihre Hilfe wird sehr geschätzt.

Dank!

InformationsquelleAutor | 2011-07-14
Schreibe einen Kommentar