我試圖將對象添加到NSMutableArray
。最初我將一些響應數據分配給數組,並可以在表格視圖中顯示它。加載更多數據後,嘗試將新信息添加到原始數組時,它似乎崩潰了。應用程序崩潰:將突變方法發送到不可變對象
我使用AFNetworking此:
[operation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) {
if(!_myArray){
_myArray = [responseObject objectForKey:@"data"];
}
else{
[_myArray addObject:[responseObject objectForKey:@"data"]];
}
[self.tableView reloadData];
}
我得到的錯誤如下
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException',
reason: '-[__NSCFArray insertObject:atIndex:]: mutating method sent to immutable object'
任何人可以幫助這嗎?