[array objectAtIndex:i]
doesn't work as an L value, so it can't be used to set the object at index i.
The only way is to create a new NSArray and change your pointer to a new NSArray. I can give an example... So basically, you can create a mutable copy temporarily, make the change you need, and then make an immutable copy. Once you have the immutable copy, you can point myArray to the new copy.
The primary difference between NSArray and NSMutableArray is that a mutable array can be changed/modified after it has been allocated and initialized, whereas an immutable array, NSArray , cannot.
The NSMutableArray class declares the programmatic interface to objects that manage a modifiable array of objects. This class adds insertion and deletion operations to the basic array-handling behavior inherited from NSArray . NSMutableArray is “toll-free bridged” with its Core Foundation counterpart, CFMutableArray .
Use -insertObject:atIndex:
or replaceObjectAtIndex:withObject:
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With