I have a NSMutableArray that is loaded with values.
Later in the application, I need to change the values of one of the elements in the array.
How do I accomplish this?
thanks tony
Take a look at the class reference instance methods:
You can use:
replaceObjectAtIndex:withObject:
given you know the index of the object.
replaceObjectsAtIndexes:withObjects:
to replace multiple objects at once.
Call -[NSMutableArray replaceObjectAtIndex:withObject:]
. Or, if the object in the array is mutable, just grab it with -objectAtIndex:
and modify its properties directly.
MyObject *obj = array[index]; obj.myProperty = newValue;
.
Commented
Jul 9, 2015 at 16:17
You would probably want to use 'replaceObjectAtIndex:withObject:' for replacing the object itself.
refer following link. It may help you
From that you can use replaceObjectAtIndex:withObject: or
replaceObjectsAtIndexes:withObjects: for replacing objects.
just you have to know the index of objects.