我在我的应用程序中有一个tableView视图,首先我从服务器获取数据并将其加载到tableView中。
-(void)viewDidLoad{
//fetching data from server using background thread and storing it in array called (msg_array)
[table reloadData];
}
当屏幕上出现最后一行时,我想从服务器获取新数据并显示它。
-(void)LoadMoreData{ //this method gets fire when last cell is on screen
if ([msg_array count]>0)
{
[msg_array removeAllObjects]; //crashes here
}
}
这会导致错误:
Terminating app due to uncaught exception 'NSInvalidArgumentException',
reason: '-[__NSArrayI removeAllObjects]: unrecognized selector sent to instance
为什么会导致崩溃:
数组是这样分配的:
msg_array = [dictShow copy];
dictshow包含数据,并将其复制到msg_array中,dictshow是可变字典
(摘自comments)