关于问题:reason: '* -[NSCFArray insertObject:atIndex:]: mutating method sent to immutable..
2015-04-01 11:13
393 查看
原本一个很小的上拉刷新 很简单 而且之前还做过,但是这次却问题百出,这个问题更是困扰了自己将近一天的时间,由于自己搞不定这个问题真的是无法入睡,于是放下手上的事情认真捋了捋思路,然后认真看了看这个文章搞定了,反复看了两边这个文章 认真理解下就能明白。
原因就是因为这个变量之前被赋值了,而无法把一个可变的方法固执给一个不可变的对象。
原文摘录如下:
错误提示:*
Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '* -[NSCFArray insertObject:atIndex:]: mutating method sent to immutable object'
问题出现在语句:
[saveArray addObject:[NSNumber numberWithInt:saveNum]];
可变的方法发送给一个不可变的对象
ps:@property(nonatomic,retain)
NSMutableArray * saveArray;
前面已经赋值:
NSMutableArray *array
= [[NSMutableArray alloc] init];
self.saveArray =
array;
[array release];
解决方法:
NSMutableArray *mutaArray
= [[NSMutableArray alloc] init];
[mutaArray addObjectsFromArray:saveArray];
[mutaArray addObject:[NSNumber numberWithInt:saveNum]];
self.saveArray
= mutaArray
[mutaArray release];
原文地址:http://blog.sina.com.cn/s/blog_6123f9650101b0zl.html
原因就是因为这个变量之前被赋值了,而无法把一个可变的方法固执给一个不可变的对象。
原文摘录如下:
错误提示:*
Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '* -[NSCFArray insertObject:atIndex:]: mutating method sent to immutable object'
问题出现在语句:
[saveArray addObject:[NSNumber numberWithInt:saveNum]];
可变的方法发送给一个不可变的对象
ps:@property(nonatomic,retain)
NSMutableArray * saveArray;
前面已经赋值:
NSMutableArray *array
= [[NSMutableArray alloc] init];
self.saveArray =
array;
[array release];
解决方法:
NSMutableArray *mutaArray
= [[NSMutableArray alloc] init];
[mutaArray addObjectsFromArray:saveArray];
[mutaArray addObject:[NSNumber numberWithInt:saveNum]];
self.saveArray
= mutaArray
[mutaArray release];
原文地址:http://blog.sina.com.cn/s/blog_6123f9650101b0zl.html
相关文章推荐
- 关于问题:reason: '* -[NSCFArray insertObject:atIndex:]: mutating method sent to immutable..
- 关于问题:reason: '* -[NSCFArray insertObject:atIndex:]: mutating method sent to immutable..
- 关于问题:reason: '* -[NSCFArray insertObject:atIndex:]: mutating method sent to immutable..
- 关于问题:reason: '* -[NSCFArray insertObject:atIndex:]: mutating method sent to immutable..
- reason: '* -[NSCFArray insertObject:atIndex:]: mutating method sent to immutable object'
- '-[__NSCFArray insertObject:atIndex:]: mutating method sent to immutable object'
- reason: '-[__NSCFArray removeObjectAtIndex:]: mutating method sent to immutable object
- reason: '-[__NSCFArray removeObjectAtIndex:]: mutating method sent to immutable object
- reason: '-[__NSCFArray removeObjectAtIndex:]: mutating method sent to immutable object' 错误
- [__NSCFArray insertObject:atIndex:]: mutating method sent to immutable objec
- NSCFArray insertObject:atIndex:]: mutating method sent to immutable obje的解决方法
- -[__NSCFArray insertObject:atIndex:]: mutating method sent to immutable obje
- -[__NSCFArray insertObject:atIndex:]: mutating method sent to immutable obje
- reason: '-[__NSCFArray removeObjectAtIndex:]: mutating method sent to immutable object
- 关于[__NSCFArray removeObjectAtIndex:]: mutating method sent to immutable object的报错分析
- reason: '-[__NSCFArray removeObjectAtIndex:]: mutating method sent to immutable object
- ios -[__NSCFArray removeObjectAtIndex:]: mutating method sent to immutable object
- -[__NSCFDictionary setObject:forKey:]: mutating method sent to immutable object' 解决方法
- -[__NSCFDictionary setObject:forKey:]: mutating method sent to immutable object' 解决方法:
- [__NSCFArray removeObjectAtIndex:]: mutating method sent to immutable object的报错分析及解决