在我的 iPhone 项目中(启用了 ARC),我有一个包含5个托管对象(从 core data 中检索出来的)的 nsmuatble
数组,在某些情况下我需要从该 nsmutablearray
中删除所有对象。
我尝试使用以下方法删除对象,但两种情况都崩溃并显示如下崩溃日志:-[__NSArrayI removeObject:]: unrecognized selector sent to instance 0xa391640
if (surveys && [surveys count]>0)
{
[surveys removeAllObjects];
surveys = [[NSMutableArray alloc]init];
}
而且我也尝试过
if (surveys && [surveys count]>0)
{
for(Survey *obj_Survey in surveys)
{
[surveys removeObject:obj_Survey];
}
surveys = [[NSMutableArray alloc]init];
}
有人能告诉我如何清空这个数组吗?任何建议都将不胜感激。谢谢!