-[__NSCFDictionary setObject:forKey:]: mutating method sent to immutable object' 解决方法

-[__NSCFDictionary setObject:forKey:]: mutating method sent to immutable object' 解决方法:

错误:NSMutableDictionary*d =[[[NSUserDefaults standardUserDefaults] objectForKey:@"xxxx"] mutableCopy];
修改:NSMutableDictionary*d =[NSMutableDictionary dictionaryWithDictionary:[[NSUserDefaults standardUserDefaults]ValueForKey:@"xxxx"]];

这里在plist里读取相关的数据后 没有alloc 崩溃的话 可能是因为这块指针指向的问题

你可能感兴趣的:(-[__NSCFDictionary setObject:forKey:]: mutating method sent to immutable object' 解决方法)