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:

  1. thank you so much, didn't find correct answer anywhere except here!

    ReplyDelete