When you're using:
[[[[inDictionary objectForKey:key]
stringByReplacingOccurrencesOfString:@"\\" withString:@"\\\\"]
stringByReplacingOccurrencesOfString:@"\"" withString:@"\\\""]
stringByReplacingOccurrencesOfString:@"\n" withString:@"\\n"]];
You're assuming that objectForKey
is going to return an NSString
object. But, in the case where your app is crashing, the object returned is actually an NSNumber
.
You should use isKindOfClass:
to determine the object type, or use stringValue
on your NSNumber
to get a string representation of the object.