iPhone-从数组中删除对象

从NSMutableArray中删除对象,下面是添加到数组的代码:

sectionInfo = [self.collectionView indexPathsForSelectedItems];

删除:

[sectionInfo removeAllObjects];

报出的错误是: unrecognized selector sent to instance 0x169cfb70

我想出错的原因是我没有将对象作为addObject添加,但是我需求是不要这样的。

貌似 indexPathsForSelectedItems 返回的类型是NSArray吧.那么对于不可变数组是没有removeAllObjects方法的.所以会报出上面的错误.改成

sectionInfo = (NSMutableArray *)[self.collectionView indexPathsForSelectedItems];

再试