Thursday, March 1, 2012

Tips for deep copy of NSMutableArray

Ok, So if you want to create a deep copy of NSMutableArray which contains items of custom class, you can refer to my old previous post HERE.

But here is the thing if your NSMutableArray contains the non custom class contains like NS(Mutable)Dictionary, you WONT be able to create deep copy by simple doing:

NSMutableArray *a= [[NSMutableArray alloc]initWithArray:b];

Rather,  you can do following trick:

NSMutableArray *a = [NSKeyedUnarchiver unarchiveObjectWithData:[NSKeyedArchiver archivedDataWithRootObject:b]];

For simple copy of array, you can read POST HERE.

1 comment: