We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 2ac2afc commit 2906c3aCopy full SHA for 2906c3a
OHHTTPStubs/OHHTTPStubsResponse+JSON.m
@@ -18,9 +18,10 @@ + (instancetype)responseWithJSONObject:(id)jsonObject
18
{
19
if (!httpHeaders[@"Content-Type"])
20
21
- NSMutableDictionary *mutableHeaders = [httpHeaders mutableCopy];
+ // If httpHeaders is nil, we can't make a mutable copy.
22
+ NSMutableDictionary *mutableHeaders = httpHeaders ? [httpHeaders mutableCopy] : [NSMutableDictionary dictionary];
23
mutableHeaders[@"Content-Type"] = @"application/json";
- httpHeaders = mutableHeaders;
24
+ httpHeaders = [mutableHeaders copy]; // make immutable again
25
}
26
27
return [self responseWithData:[NSJSONSerialization dataWithJSONObject:jsonObject options:0 error:nil]
0 commit comments