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

时间:2015-02-11 19:07:02   收藏:0   阅读:2808

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

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!