NSDictionary-MutableDeepCopyOfArrays.m
上传用户:jjjjag8
上传日期:2017-04-17
资源大小:1443k
文件大小:1k
源码类别:
iPhone
开发平台:
MultiPlatform
- #import "NSDictionary-MutableDeepCopyOfArrays.h"
- @implementation NSDictionary (MutableDeepCopyOfArrays)
- - (NSMutableDictionary *)mutableDeepCopyOfArrays
- {
- NSMutableDictionary *ret = [NSMutableDictionary dictionaryWithCapacity:[self count]];
- NSArray *keys = [self allKeys];
- for (id key in keys)
- {
- NSArray *oneArray = [self valueForKey:key];
- NSMutableArray *arrayCopy = [[NSMutableArray alloc] initWithArray:oneArray];
- [ret setValue:arrayCopy forKey:key];
- [arrayCopy release];
- }
- return ret;
- }
- - (NSMutableDictionary *) mutableDeepCopy
- {
- NSMutableDictionary *ret = [NSMutableDictionary dictionaryWithCapacity:[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;
- }
- @end