こんにちは、for ループを使用して NSMutableDictionary に 2 つの NSMutableArray データを入力しようとしましたが、ループが終了すると、NSMutableDictionary は最後にロードされた値のみを表示します。コードに従ってください
-(void)calculateDistance
{
self.distanceArray=[[NSMutableArray alloc]init];
self.dict=[[NSMutableDictionary alloc]init];
for (int i=0; i<[self.nombre count]; i++) {
CLLocation *shopPosition=[[CLLocation alloc]initWithLatitude:[[self.latitud objectAtIndex:i] floatValue]longitude:[[self.longitud objectAtIndex:i]floatValue]];
self.userPosition=[[CLLocation alloc]initWithLatitude:self.currentLat longitude:self.currentLong];
self.distance=[shopPosition distanceFromLocation:self.userPosition];
[self.distanceArray addObject:[NSNumber numberWithFloat:self.distance]];
[self.dict setObject:[self.distanceArray objectAtIndex:i] forKey:@"distance"];
[self.dict setObject:[self.nombre objectAtIndex:i] forKey:@"nombre"];
}
NSLog(@" DICT %@",self.dict);
どうもありがとう