copy array into another array
I have an NSMutableArray
something like this
array =[[a1,b1,c1],[a2,b2,c2],[a3,b3,c3].......]
and I access this array for particular object like
array.a =[a1,a2,a3]
array.b =[b1,b2,b3]
what I am trying to do is to copy all elements which are in array.b
into an another array say arrayABC
.
some开发者_运维知识库thing like this arrayABC = [a1,a2,a3....]
HOw can i do that.. suggestions are always appreciated..
regards
You could use the "arrayWithArray" class method in NSArray:
NSArray *newABC = [NSArray arrayWithArray:someOtherArray];
See http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Classes/NSArray_Class/NSArray.html%23//apple_ref/doc/uid/20000137-BABCADBE
i think i got my answer by myself
[newArray addObject:array.A];
it works for me....
Swift version for the checked response :
let array = NSArray(array: myarray)
Also for mutable array :
let array = NSMutableArray(array: mymutablearray)
精彩评论