Thursday, June 16, 2011

Copy items of NSMutableArray into another ?

Lets say you have arrayA and arrayB, arrayB could be NSArray or NSMutableArray.
But arrayA should be mutable.

  [arrayA addObjectsFromArray:arrayB];

Here you are copying items from  arrayB to arrayA. Make sure you have already alloc memory for arrayA as:

arrayA = [[NSMutableArray alloc]init];

Case 2: If you want to create a copy an array to NSArray, you can do so as following:

NSArray *db=[[NSArray alloc]initWithArray:availListArray];

No comments:

Post a Comment