Intermittent Crash: - setObjectForKey: Object cannot be nil (key:ref_id)
Intermittent Crash: - setObjectForKey: Object cannot be nil.(key: ref_id)
ref_id object is string/number in the JSON response.
Same code works most of the time. But sometime it crashes (~less than 5%).
NSDictionary *udfDict = nil;
if (data) {
if ([data length] > 0) {
udfDict = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers error:&serializationError];
}
}
if (udfDict) {
NSString *transactionreason;
NSString *refId;
if (![CustomUtilities isEmptyOrNull:udfDict[@"ref_id"]]) {
refId = udfDict[@"ref_id"];
[dict setObject:refId forKey:@"ref_id"];
}
Concern: If its not able to downcast from number to string, the code should break all the time.But thats not the case.The crash is intermittent and only code breaks for ~5% occurances.
iPhone 6s, iOS 9.2, Xcode7.2