美文网首页
关于使用NSMutableArray,removeObjectA

关于使用NSMutableArray,removeObjectA

作者: 博BlingBing | 来源:发表于2016-07-18 16:42 被阅读808次

使用规范
@property (nonatomic, strong) NSMutableArray *historyArr;
_historyArr = [[NSMutableArray alloc]init];
_historyArr = data;
直接进行赋值,会让NSMutableArray转变为NSArray.这样执行 removeObjectAtIndex就会不成功,造成crash
规范:
[weakSelf.historyArr addObjectsFromArray:data];//未这样写,而是直接赋值,所以出现错误。
// 从列表中删除
[weakSelf.historyArr removeObjectAtIndex:indexPath.row];

相关文章

网友评论

      本文标题:关于使用NSMutableArray,removeObjectA

      本文链接:https://www.haomeiwen.com/subject/kzopjttx.html