2013-10-21 4 views
0

무엇이 잘못 되었습니까? 나는 총 거리를 얻으려고 노력하고 있지만, 내가 운전을 시작할 때 나는 내 가치가 떨어지기 시작 했단 말인가? 무엇을 고칠 필요가 있습니다. 고맙습니다.정확한 거리 측정

-(void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation { 
    if (startLocation == nil) 
    { 
     self.totalDistanceBetween = 0; // declare this variable 
     self.startLocation = newLocation; 
    } 
    CLLocationDistance distanceBetween = [newLocation distanceFromLocation:startLocation ]; 
    startLocation = newLocation; 
    self.totalDistanceBetween += distanceBetween; // declare this variable 
    NSString *tripString = [[NSString alloc]  //convert to string 
          initWithFormat:@"%f", 
          self.totalDistanceBetween]; 
    distance.text = tripString; //update my distance label called distance 
} 

답변

1

이 방법을 시도?
+0

변수 유형이 될 totaldistancebetween한다 :

-(void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation { if (startLocation == nil) self.startLocation = newLocation; //if this is the first update colocation called startlocation = new location CLLocationDistance distanceBetween = [newLocation distanceFromLocation:startLocation]; //here is my problem I think NSString *tripString = [[NSString alloc] //convert to string initWithFormat:@"%f", distanceBetween]; distance.text = tripString; //update my distance label called distance } 
4GetFullOf

+0

@Rookie CLLocationDistance 또는 double –

+0

@Rookie이 클래스의 멤버 또는 정적 변수로 선언해야하지만 함수 내에 포함되지 않아야합니다. –