Objective c 更新数组中的值

Objective c 更新数组中的值,objective-c,ios5,Objective C,Ios5,如何更新数组每行中的单个值 例如,我有一个从SQL DB创建的数组,其中包含以下列 Name Address Lat Long Distance 距离最初设置为0,直到从Lat/Long计算。我想用计算出的距离更新该0 我找到的每个示例都没有显示如何更新每行的一列 NSMutableArray *barInfo = [BarDatabase database].barInfo; for (Bars *info in barInfo) { NSLog(@"%@, %@, %@, %@,

如何更新数组每行中的单个值

例如,我有一个从SQL DB创建的数组,其中包含以下列

Name
Address
Lat
Long
Distance
距离最初设置为0,直到从Lat/Long计算。我想用计算出的距离更新该0

我找到的每个示例都没有显示如何更新每行的一列

NSMutableArray *barInfo = [BarDatabase database].barInfo;
for (Bars *info in barInfo) {
    NSLog(@"%@, %@, %@, %@, %@", info.barName, info.barAddress, info.Lat, info.Long, info.cachedDist);
    NSString *strLat = info.Lat;
    NSString *strLong = info.Long;
    CLLocation *barLocation = [[CLLocation alloc] initWithLatitude:[strLat doubleValue] longitude:[strLong doubleValue]];
    CLLocationDistance bdistance = [currentLat distanceFromLocation:barLocation]/1000;
    [barInfo addObject:bdistance];
}

我正在使用NSMutableArray,因为我不知道如何修改NSArray中的距离字段。我知道苹果说这是可能的,但我找不到。

展示你目前如何构建阵列的代码可能会非常有用。我添加了我目前掌握的代码。你能提供关于条形图的信息吗?NSArray和NSMutableArray只包含指向Bars类型对象的指针。要更新单个Bars对象,您需要使用该对象的@properties。我在Bars中有一个NSString CachedList属性。如果你需要更多信息,请告诉我。