30 :(NSDictionary *)otherDictionary
31{
32 NSEnumerator *otherKeysEnum =
nil;
34
35 for (otherKeysEnum = [otherDictionary keyEnumerator]; (key = [otherKeysEnum nextObject]); )
36 {
37 if (![self objectForKey:key])
38 [self setObject:[otherDictionary objectForKey:key] forKey:key];
39 else
40 {
41 BOOL merged = NO;
42 id thisObject = [self objectForKey:key];
43 id otherObject = [otherDictionary objectForKey:key];
44
45 if ([thisObject isKindOfClass:[NSDictionary class]]&&[otherObject isKindOfClass:[NSDictionary class]]&&(![thisObject isEqual:otherObject]))
46 {
47 NSMutableDictionary* mergeObject = [NSMutableDictionary dictionaryWithDictionary:(NSDictionary*)thisObject];
48 [mergeObject mergeEntriesFromDictionary:(NSDictionary*)otherObject];
49 [self setObject:mergeObject forKey:key];
50 merged = YES;
51 }
52
53 if ([thisObject isKindOfClass:[NSArray class]]&&[otherObject isKindOfClass:[NSArray class]]&&(![thisObject isEqual:otherObject]))
54 {
55 NSMutableArray* mergeObject = [NSMutableArray arrayWithArray:(NSArray*)thisObject];
56 [mergeObject addObjectsFromArray:(NSArray*)otherObject];
57 [self setObject:mergeObject forKey:key];
58 merged = YES;
59 }
60
61 if (!merged)
62 [self setObject:otherObject forKey:key];
63 }
64 }
65}