0
我試圖添加到一個可變數組中,並且無法弄清楚。將不兼容的數據類型double的錯誤引發到id。問題是我如何轉換距離並將其存儲在我的數組中。轉換cllocationdistance中的數據的問題
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);
我想保存在我的數組「locationDistance」「距離」
感謝您的幫助,我還是新到iOS以及編程一般。
謝謝[NSNumber numberWithDouble:distance]是我所需要的 –