so I want to copy an object from an NSMutableArray:
self.myObject = [self.myMutableArray objectAtIndex:self.currentIndex];
But when currentIndex changes, myObject changes to the object corresponding to the new index.
What is the best way to approach this?
Edit:
Here’s more or less what I’m trying to achieve:
self.currentIndex = 0;
self.myObject = [self.myMutableArray objectAtIndex:self.currentIndex];
self.currentIndex = 1;
//After here I want myObject to remain the same, but it doesn't
Invoke the
copymethod on the object from the array, and then take care of releasing it yourself: