30 CPArray _includedKeys;
31 CPArray _excludedKeys;
44 _initialValue =
@"value";
52 var keys = [_contentDictionary allKeys],
56 if ([keys containsObject:newKey])
57 while ([keys containsObject:newKey])
60 return [
self _newObjectWithKey:newKey value:_initialValue];
63 - (id)_newObjectWithKey:(
CPString)aKey value:(
id)aValue
65 var aNewObject = [_CPDictionaryControllerKeyValuePair new];
67 aNewObject._dictionary = _contentDictionary;
68 aNewObject._controller =
self;
69 aNewObject._key = aKey;
72 [aNewObject setValue:aValue];
79 return _contentDictionary;
84 if (aDictionary == _contentDictionary)
88 _contentDictionary = aDictionary;
90 _contentDictionary = nil;
92 var array = [CPArray array],
93 allKeys = [_contentDictionary allKeys];
95 [allKeys addObjectsFromArray:_includedKeys];
97 var iter = [[CPSet setWithArray:allKeys] objectEnumerator],
100 while ((obj = [iter nextObject]) !== nil)
101 if (![_excludedKeys containsObject:obj])
102 [array addObject:[
self _newObjectWithKey:obj value:nil]];
122 _includedKeys = [aCoder decodeObjectForKey:CPIncludedKeys];
123 _excludedKeys = [aCoder decodeObjectForKey:CPExcludedKeys];
124 _initialKey =
@"key";
125 _initialValue =
@"value";
135 [aCoder encodeObject:_includedKeys forKey:CPIncludedKeys];
136 [aCoder encodeObject:_excludedKeys forKey:CPExcludedKeys];
144 @implementation _CPDictionaryControllerKeyValuePair :
CPObject 153 return [_dictionary objectForKey:_key];
156 - (void)setValue:(
id)aValue
158 [_dictionary setObject:aValue forKey:_key];
161 - (BOOL)isExplicitlyIncluded
163 return [[_controller _includedKeys] containsObject:_key];
174 - (CPArray)includedKeys
176 return _includedKeys;
182 - (void)setIncludedKeys:(CPArray)aValue
184 _includedKeys = aValue;
190 - (CPArray)excludedKeys
192 return _excludedKeys;
198 - (void)setExcludedKeys:(CPArray)aValue
200 _excludedKeys = aValue;
216 _initialKey = aValue;
224 return _initialValue;
230 - (void)setInitialValue:(
id)aValue
232 _initialValue = aValue;
id initWithCoder:(CPCoder aCoder)
void encodeWithCoder:(CPCoder aCoder)
A mutable key-value pair collection.
void setContent:(id value)
An immutable string (collection of characters).
Defines methods for use when archiving & restoring (enc/decoding).
id stringWithFormat:(CPString format, [,] ...)