File tree Expand file tree Collapse file tree 1 file changed +6
-4
lines changed
stdlib/public/Darwin/Foundation Expand file tree Collapse file tree 1 file changed +6
-4
lines changed Original file line number Diff line number Diff line change @@ -265,8 +265,9 @@ fileprivate struct _PlistKeyedEncodingContainer<K : CodingKey> : KeyedEncodingCo
265
265
}
266
266
267
267
public mutating func nestedContainer< NestedKey> ( keyedBy keyType: NestedKey . Type , forKey key: Key ) -> KeyedEncodingContainer < NestedKey > {
268
- let dictionary = NSMutableDictionary ( )
269
- self . container [ key. stringValue] = dictionary
268
+ let containerKey = key. stringValue
269
+ let dictionary = self . container [ containerKey] as? NSMutableDictionary ?? NSMutableDictionary ( )
270
+ self . container [ containerKey] = dictionary
270
271
271
272
self . codingPath. append ( key)
272
273
defer { self . codingPath. removeLast ( ) }
@@ -276,8 +277,9 @@ fileprivate struct _PlistKeyedEncodingContainer<K : CodingKey> : KeyedEncodingCo
276
277
}
277
278
278
279
public mutating func nestedUnkeyedContainer( forKey key: Key ) -> UnkeyedEncodingContainer {
279
- let array = NSMutableArray ( )
280
- self . container [ key. stringValue] = array
280
+ let containerKey = key. stringValue
281
+ let array = self . container [ containerKey] as? NSMutableArray ?? NSMutableArray ( )
282
+ self . container [ containerKey] = array
281
283
282
284
self . codingPath. append ( key)
283
285
defer { self . codingPath. removeLast ( ) }
You can’t perform that action at this time.
0 commit comments