首页 > 其他 > 详细

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

时间:2015-02-11 19:07:02      阅读:2806      评论:0      收藏:0      [点我收藏+]

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


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

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



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

原文:http://zerolee1213.blog.51cto.com/9835168/1613607

(0)
(1)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!