开发者

How to copy an NSMutableArray to anotherNSMutableArray

开发者 https://www.devze.com 2023-01-12 20:25 出处:网络
If i have 2 NSMutableArray declared in .h, synthesize in .m files, how can i copy whole contents of array 1 to 2? actually the sam开发者_JAVA技巧e array.

If i have 2 NSMutableArray declared in .h, synthesize in .m files, how can i copy whole contents of array 1 to 2? actually the sam开发者_JAVA技巧e array.

I tried using this code only:

[self.data addObjectsFromArray:self.temparray]

to copy data from temparray to data.

doesn't seems to work.....


Did you initialize your self.data at all? I.e. self.data = [NSMutableArray array]; somewhere.

If you did, please post some code.


- (NSArray *)arrayByAddingObjectsFromArray:(NSArray *)otherArray

is the method your looking for.

0

精彩评论

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