i have a NSMutableArray. In this is the structure of my Array:
{
Distance = 0;
Name = Name1;
Town = Town1;
}
{
Distance = 0;
Name = Name2;
Town = Town2;
}
And now I want to replace "Distance". For example that "Distance = 15".
How can I do this?
OK, let's say your initial NSMutableArray is called initial (given that it contains NSMutableDictionary objects...
To alter the first element's distance value :
[[initial objectAtIndex:0] setValue:[NSNumber numberWithInt:15]
forKey:@"Distance"];
IF you want to perform the correction for every entry in the array, just do it this way :
for (NSMutableDictionary* entry in initial)
{
[entry setValue:[NSNumber numberWithInt:15]
forKey:@"Distance"];
}
NSMutableDictionary. If they're just NSDictionary instances (= IMmutable), how could they be altered?news = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers error:NULL];. It should work.