Skip to content
Snippets Groups Projects
Commit acf5e107 authored by Jorge Canizales's avatar Jorge Canizales
Browse files

Let remove nil or non-ASCII keys (noop instead of throw).

parent 12da424c
No related branches found
No related tags found
No related merge requests found
......@@ -38,8 +38,8 @@
#import "GRPCCall.h"
#import "NSDictionary+GRPC.h"
// Used by the setters.
static NSString* NormalizeKey(NSString* key) {
// Used by the setter.
static void CheckKeyIsValid(NSString* key) {
if (!key) {
[NSException raise:NSInvalidArgumentException format:@"Key cannot be nil"];
}
......@@ -47,7 +47,6 @@ static NSString* NormalizeKey(NSString* key) {
[NSException raise:NSInvalidArgumentException
format:@"Key %@ contains non-ASCII characters", key];
}
return key.lowercaseString;
}
// Precondition: key isn't nil.
......@@ -93,14 +92,15 @@ static void CheckKeyValuePairIsValid(NSString *key, id value) {
- (void)setObject:(id)obj forKeyedSubscript:(NSString *)key {
[self checkCallIsNotStarted];
key = NormalizeKey(key);
CheckKeyIsValid(key);
key = key.lowercaseString;
CheckKeyValuePairIsValid(key, obj);
_proxy[key] = obj;
}
- (void)removeObjectForKey:(NSString *)key {
[self checkCallIsNotStarted];
[_proxy removeObjectForKey:NormalizeKey(key)];
[_proxy removeObjectForKey:key.lowercaseString];
}
- (void)removeAllObjects {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment