所以我想复制一个对象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)
copy从数组调用对象上的方法,然后自己解决它:
self.myObject = [[self.myMutableArray objectAtIndex:5] copy];
...
[self.myObject release];
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
94 次 |
| 最近记录: |