ObjFW  Check-in [bb8de03577]

Overview
Comment:OFMutableDictionary: Allow dict[key] = nil

-[setObject:forSubscriptedKey:] is supposed to support removing a key by
setting it to nil.

Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: bb8de035779e28c1521c53d0fc83c317262b1d1a4a74132f583c0f405eda0b4e
User & Date: js on 2017-11-16 23:42:00
Other Links: manifest | tags
Context
2017-11-18
17:45
Fix several Doxygen warnings check-in: 31e6b7ce9c user: js tags: trunk
2017-11-16
23:42
OFMutableDictionary: Allow dict[key] = nil check-in: bb8de03577 user: js tags: trunk
2017-11-14
23:30
Fix -[OFURL initFileURLWithPath:] on Windows check-in: 8dd0438ada user: js tags: trunk
Changes

Modified src/OFMutableArray.h from [9bb82b7b0e] to [1118eb94b2].

105
106
107
108
109
110
111











112
113
114
115
116
117
118
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129







+
+
+
+
+
+
+
+
+
+
+







 * @brief Replaces the object at the specified index with the specified object.
 *
 * @param index The index of the object to replace
 * @param object The replacement object
 */
- (void)replaceObjectAtIndex: (size_t)index
		  withObject: (ObjectType)object;

/*!
 * @brief Replaces the object at the specified index with the specified object.
 *
 * This method is the same as @ref replaceObjectAtIndex:withObject:.
 *
 * This method is also used by the subscripting syntax.
 *
 * @param index The index of the object to replace
 * @param object The replacement object
 */
-    (void)setObject: (ObjectType)object
  atIndexedSubscript: (size_t)index;

/*!
 * @brief Replaces the first object that has the same address as the specified
 *	  object with the other specified object.
 *

Modified src/OFMutableDictionary.h from [432341193d] to [4bdbc2aa53].

59
60
61
62
63
64
65
66

67
68
69
70
71
72












73

74
75
76
77
78
79
80
59
60
61
62
63
64
65

66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84

85
86
87
88
89
90
91
92







-
+






+
+
+
+
+
+
+
+
+
+
+
+
-
+







 * @return An initialized OFMutableDictionary
 */
- (instancetype)initWithCapacity: (size_t)capacity;

/*!
 * @brief Sets an object for a key.
 *
 * A key can be any object that conforms to the OFCopying protocol.
 * A key can be any object that conforms to the @ref OFCopying protocol.
 *
 * @param key The key to set
 * @param object The object to set the key to
 */
- (void)setObject: (ObjectType)object
	   forKey: (KeyType)key;

/*!
 * @brief Sets an object for a key.
 *
 * A key can be any object that conforms to the @ref OFCopying protocol.
 *
 * This method is also used by the subscripting syntax.
 *
 * @param key The key to set
 * @param object The object to set the key to. If it is nil, this is equal to
 *		 calling @ref removeObjectForKey:.
 */
-   (void)setObject: (ObjectType)object
-   (void)setObject: (nullable ObjectType)object
  forKeyedSubscript: (KeyType)key;

/*!
 * @brief Removes the object for the specified key from the dictionary.
 *
 * @param key The key whose object should be removed
 */

Modified src/OFMutableDictionary.m from [ca6e54d9b6] to [1ad5b29420].

166
167
168
169
170
171
172

173
174




175
176
177
178
179
180
181
166
167
168
169
170
171
172
173


174
175
176
177
178
179
180
181
182
183
184







+
-
-
+
+
+
+







{
	OF_UNRECOGNIZED_SELECTOR
}

-   (void)setObject: (id)object
  forKeyedSubscript: (id)key
{
	if (object != nil)
	[self setObject: object
		 forKey: key];
		[self setObject: object
			 forKey: key];
	else
		[self removeObjectForKey: key];
}

- (void)removeObjectForKey: (id)key
{
	OF_UNRECOGNIZED_SELECTOR
}