- 異常1
hello world
Terminating app due to uncaught exception 'NSInternalInconsistencyException',
reason:
'-[__NSCFDictionary setObject:forKey:]:
mutating method sent to immutable object'
- 解決方法:
將如下代碼
NSData *jsonData =
[NSJSONSerialization
dataWithJSONObject:dictionary options:
NSJSONWritingPrettyPrinted error:&error];
改成:
NSData *jsonData ;
if ([NSJSONSerialization isValidJSONObject:dictionary]) {
jsonData = [NSJSONSerialization dataWithJSONObject:dictionary
options:0 error: &error];
}
- 異常 2
Terminating app due to uncaught exception 'NSInternalInconsistencyException',
reason: '-[__NSCFDictionary setObject:forKey:]:
mutating method sent to immutable object'
將如下代碼
NSMutableDictionary *cacheDic =
[USER_DEFAULT objectForKey:HttpExpiredCacheArrayKey];
改成
NSMutableDictionary *cacheDic =
[NSMutableDictionary dictionaryWithDictionary:
[USER_DEFAULT objectForKey:HttpExpiredCacheArrayKey]];