Oolite
Loading...
Searching...
No Matches
NSDictionary(OOExtensions) Category Reference

#include <NSDictionaryOOExtensions.h>

Instance Methods

(NSDictionary *) - dictionaryByAddingObject:forKey:
(NSDictionary *) - dictionaryByRemovingObjectForKey:
(NSDictionary *) - dictionaryByAddingEntriesFromDictionary:

Detailed Description

Definition at line 32 of file NSDictionaryOOExtensions.h.

Method Documentation

◆ dictionaryByAddingEntriesFromDictionary:

- (NSDictionary *) dictionaryByAddingEntriesFromDictionary: (NSDictionary*) dictionary

Definition at line 60 of file NSDictionaryOOExtensions.m.

60 :(NSDictionary*)dictionary
61{
62 // Note: object lifetime issues aside, we need to copy and autorelease so that the right thing happens for mutable dictionaries.
63 if (dictionary == nil)
64 return [[self copy] autorelease];
65
66 NSMutableDictionary* temp = [self mutableCopy];
67 [temp addEntriesFromDictionary:dictionary];
68 NSDictionary* result = [[temp copy] autorelease];
69 [temp release];
70
71 return result;
72}
return nil

References nil.

◆ dictionaryByAddingObject:forKey:

- (NSDictionary *) dictionaryByAddingObject: (id) object
forKey: (id) key 

Definition at line 32 of file NSDictionaryOOExtensions.m.

32 :(id)object forKey:(id)key
33{
34 // Note: object lifetime issues aside, we need to copy and autorelease so that the right thing happens for mutable dictionaries.
35 if (object == nil || key == nil)
36 return [[self copy] autorelease];
37
38 NSMutableDictionary* temp = [self mutableCopy];
39 [temp setObject:object forKey:key];
40 NSDictionary* result = [[temp copy] autorelease];
41 [temp release];
42
43 return result;
44}

References nil.

◆ dictionaryByRemovingObjectForKey:

- (NSDictionary *) dictionaryByRemovingObjectForKey: (id) key

Definition at line 46 of file NSDictionaryOOExtensions.m.

46 :(id)key
47{
48 // Note: object lifetime issues aside, we need to copy and autorelease so that the right thing happens for mutable dictionaries.
49 if (key == nil)
50 return [[self copy] autorelease];
51
52 NSMutableDictionary* temp = [self mutableCopy];
53 [temp removeObjectForKey:key];
54 NSDictionary* result = [[temp copy] autorelease];
55 [temp release];
56
57 return result;
58}

References nil.


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