2012-05-15 1 views
0

변경 가능한 배열에 추가하려고하는데이를 이해할 수 없습니다. 양립 할 수없는 데이터 형 double에 대해서, id에 double를 throw합니다. 질문은 거리를 변환하고 배열에 저장하는 방법입니다. 내 배열 "locationDistance"에서 "거리"어떤 도움위치 테이블의 데이터를 변환하는 중 문제가 발생했습니다.

감사를 저장하기 위해 노력하고

for (int i = 0; i < _getAllLocations.count; i++) { 

uscInfo *entity = [_getAllLocations objectAtIndex:i]; 
NSNumber *numlat=[[NSNumber alloc] initWithDouble:[entity.Latitude doubleValue]]; 
NSNumber *numlon=[[NSNumber alloc] initWithDouble:[entity.Longitude doubleValue]]; 
NSLog(@"%d",[_getAllLocations count]); 
la=[numlat doubleValue]; 
lo=[numlon doubleValue]; 
CLLocation *currentLocation = [[CLLocationalloc]initWithLatitude:lalongitude:lo];////here put your destination point 

//NSLog(@"New Location:%@", newLocation); 
CLLocationDistance distance = [newLocation distanceFromLocation:currentLocation]; 
NSLog(@"%@ (%@) %4.0f km from current location",entity.EntityNo, entity.EntityName, distance); 
NSLog(@"%@",currentLocation); 

, 나는 여전히 일반적으로 아이폰 OS의 새로운뿐만 아니라 프로그램입니다. ,

하지만 문제는 가능성이 배열에 벌거 벗은 CLLocationDistance을 추가하려고 있음을 알 수 있습니다 -

답변

1

(이 경우에 실제 addObject: 코드를. 당신은 정말 작동하지 않는 코드를 포함한다) 그것은 대상이 아니기 때문에 작동하지 않을 것입니다. typedef '을 double으로 지정하여 포장하십시오 (예 : [NSNumber numberWithDouble:distance]).

+0

[NSNumber numberWithDouble : distance] 감사합니다. –