0

可変配列に追加しようとしていますが、これを理解できません。互換性のないデータ型 double から id に対してエラーをスローします。問題は、距離を変換して配列に格納する方法です。

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とプログラミング全般に不慣れです。

4

1 に答える 1

1

(実際には、動作していないコード (この場合は実際のaddObject:コード) を含める必要があります。)

しかし、問題は、裸の CLLocationDistance を配列に追加しようとしている可能性が高いことです。これはオブジェクトではないため機能しません。として表示さtypedefれるdoubleので、たとえば を使用してラップする必要があります[NSNumber numberWithDouble:distance]

于 2012-05-15T17:29:24.533 に答える