Oolite 1.91.0.7645-241119-222d325
Loading...
Searching...
No Matches
NSMutableDictionary(OOExtensions) Category Reference

#include <NSMutableDictionaryOOExtensions.h>

Instance Methods

(void) - mergeEntriesFromDictionary:
 

Detailed Description

Definition at line 29 of file NSMutableDictionaryOOExtensions.h.

Method Documentation

◆ mergeEntriesFromDictionary:

- (void) mergeEntriesFromDictionary: (NSDictionary *) otherDictionary

Definition at line 1 of file NSMutableDictionaryOOExtensions.m.

30 :(NSDictionary *)otherDictionary
31{
32 NSEnumerator *otherKeysEnum = nil;
33 id key = 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}
return nil

References nil.


The documentation for this category was generated from the following files: