简体   繁体   中英

How to copy an NSMutableArray to anotherNSMutableArray

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 same 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? Ie self.data = [NSMutableArray array]; somewhere.

If you did, please post some code.

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

是您要寻找的方法。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM