开发者

Need clarification on addObjectsFromArray function

I have the following code (both items and itemsCopy are NSMutableArray's):

//DO: populate items w/ 30 elements
[self.itemsCopy addObjectsFromArray:self.items];
//DO: remove all ele开发者_高级运维ments in items

Results

Begin Pass 1:
itemsCopy = 0
items = 30

End Pass 1:
itemsCopy = 30
items = 0

Begin Pass 2:
itemsCopy = 0
items = 30

End Pass 2:
itemsCopy = 30
items = 0

How can I constantly append items to the end of itemsCopy? I would like the scenario to look like this:

Begin Pass 1:
itemsCopy = 0
items = 30

End Pass 1:
itemsCopy = 30;
items = 0;

Begin Pass 2:
itemsCopy = 30
items = 30

End Pass 2:
itemsCopy = 60
items = 0


By keeping the same array you just filled in the itemsCopy property. It's clearly being reset to an empty array with whatever method you're using.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜