NSMutableArray 使用replaceObjectAtIndex: withObject:时出错!!!

NSMutableArray 使用replaceObjectAtIndex: withObject:时出错,提示 “-[__NSCFArray removeObjectAtIndex:]: mutating method sent to immutable object ”


解决方法:建议在所有程序生成的数组里加上mutableCopy 这个方法 

例如: 
NSMutableArray* favoritedAlready = [[[NSUserDefaults standardUserDefaults] objectForKey:@"favorites"] mutableCopy]; 
如果没加mutablecopy的话 standaradUserdefault会返回一个arrary 这样就会出错 
希望能帮到你



文章来自:http://zerolee1213.blog.51cto.com/9835168/1613607
© 2021 jiaocheng.bubufx.com  联系我们
ICP备案:鲁ICP备09046678号-3