从NSMutableArray复制对象的正确方法是什么

soo*_*per 0 objective-c ios

所以我想复制一个对象NSMutableArray:

self.myObject = [self.myMutableArray objectAtIndex:self.currentIndex];
Run Code Online (Sandbox Code Playgroud)

但是当currentIndex更改时,myObject对象的更改对应于新索引.

解决这个问题的最佳方法是什么?

编辑:

这或多或少是我想要实现的目标:

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
Run Code Online (Sandbox Code Playgroud)

Bla*_*iev 6

copy从数组调用对象上的方法,然后自己解决它:

self.myObject = [[self.myMutableArray objectAtIndex:5] copy];
...
[self.myObject release];
Run Code Online (Sandbox Code Playgroud)