Este un dictionar ce contine mai multe array-uri care contin la randul lor NSString-uri.
Din cate stiu eu copiile NSDictionary NSArray si NSSet sunt shallow by default.
@implementation NSDictionary (MutableDeepCopy) - (NSMutableDictionary *) mutableDeepCopy { NSMutableDictionary *ret = [[NSMutableDictionary alloc] initWithCapacity:[self count]]; NSArray *keys = [self allKeys]; for (id key in keys) { id oneValue = [self valueForKey:key]; id oneCopy = nil; if ([oneValue respondsToSelector:@selector(mutableDeepCopy)]) oneCopy = [oneValue mutableDeepCopy]; else if ([oneValue respondsToSelector:@selector(mutableCopy)]) oneCopy = [oneValue mutableCopy]; if (oneCopy == nil) oneCopy = [oneValue copy]; [ret setValue:oneCopy forKey:key]; return ret; } return ret; } @end
Nu inteleg cum se realizeaza deep copy in codul de mai sus.
O metoda pentru deep copy care o stiu ar fi prin NSKeyedArchiver/NSKeyedUnarchiver:
array2 = [NSKeyedUnarchiver unarchiveObjectWithData: [NSKeyedArchiver archiveDataWithRootObject: array1];