현재 위치에서 대상 위치까지의 거리를 얻기 위해 for 루프를 사용하고 있습니다. 현재 위치에서 목적지까지의 모든 거리가 포함 된 배열을 원합니다.'for'루프에 의해 생성 된 배열에 요소를 추가하는 방법은 무엇입니까?
for (i = 0; i < [Arr_Lat count]; i++)
{
NSString *latst1 = [[NSString alloc]initWithFormat:[Arr_Lat objectAtIndex:i]];
NSString *longst1 = [[NSString alloc]initWithFormat:[Arr_Long objectAtIndex:i]];
NSLog(@"First lat : %@",latst1);
NSLog(@"First ong : %@",longst1);
double Doblat1 = [latst1 doubleValue];
double Doblong1 = [longst1 doubleValue];
CLLocationCoordinate2D coord1 = CLLocationCoordinate2DMake(coord1.latitude = Doblat1, coord1.longitude = Doblat1);
NSLog(@" Coordinat ==== : %f -- %f",coord1.latitude,coord1.longitude) ;
CLLocation *currLoc = [[CLLocation alloc] initWithLatitude:appDel.curr_lat longitude:appDel.curr_long];
CLLocation *destLoc1 = [[CLLocation alloc] initWithLatitude:Doblat1 longitude:Doblong1];
NSLog(@" Currennt Location : %@", currLoc);
NSLog(@" Destination Location : %@" , destLoc1);
distance = [destLoc1 distanceFromLocation:currLoc];
NSLog(@" Distance : ------- %0.3f", distance);
DistStr = [[NSString alloc]initWithFormat:@" %f",distance];
[currLoc release];
[destLoc1 release];
[Arr_title retain];
[tbl_nearplace reloadData];
}
예. 알겠습니다. 고마워 ........... –
환영/................ – Venkat