Skip to content

Commit 56f503b

Browse files
authored
Fix GULMutableDictionary keyed subscript methods (#3882)
1 parent 520c8d6 commit 56f503b

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

GoogleUtilities/Network/GULMutableDictionary.m

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,14 @@ - (NSString *)description {
4545
- (id)objectForKey:(id)key {
4646
__block id object;
4747
dispatch_sync(_queue, ^{
48-
object = self->_objects[key];
48+
object = [self->_objects objectForKey:key];
4949
});
5050
return object;
5151
}
5252

5353
- (void)setObject:(id)object forKey:(id<NSCopying>)key {
5454
dispatch_async(_queue, ^{
55-
self->_objects[key] = object;
55+
[self->_objects setObject:object forKey:key];
5656
});
5757
}
5858

@@ -77,13 +77,17 @@ - (NSUInteger)count {
7777
}
7878

7979
- (id)objectForKeyedSubscript:(id<NSCopying>)key {
80-
// The method this calls is already synchronized.
81-
return [self objectForKey:key];
80+
__block id object;
81+
dispatch_sync(_queue, ^{
82+
object = self->_objects[key];
83+
});
84+
return object;
8285
}
8386

8487
- (void)setObject:(id)obj forKeyedSubscript:(id<NSCopying>)key {
85-
// The method this calls is already synchronized.
86-
[self setObject:obj forKey:key];
88+
dispatch_async(_queue, ^{
89+
self->_objects[key] = obj;
90+
});
8791
}
8892

8993
- (NSDictionary *)dictionary {

0 commit comments

Comments
 (0)