Ios 如何在NSMutableArray中存储indexPath时传入节值

Ios 如何在NSMutableArray中存储indexPath时传入节值,ios,uicollectionview,nsmutablearray,nsindexpath,Ios,Uicollectionview,Nsmutablearray,Nsindexpath,我正在尝试将indexPath存储在NSMutableArray中 [checkBoxIndexArray addObject:[NSIndexPath indexPathForRow:indexPath.row inSection:?]]; - (void)reloadItemsAtIndexPaths:(NSArray<NSIndexPath *> *)indexPaths { cell.checkBox.image = [UII

我正在尝试将indexPath存储在NSMutableArray中

    [checkBoxIndexArray addObject:[NSIndexPath indexPathForRow:indexPath.row inSection:?]];


   - (void)reloadItemsAtIndexPaths:(NSArray<NSIndexPath *> *)indexPaths
    {

           cell.checkBox.image = [UIImage imageNamed:@"check"];

           [self.collectionView insertItemsAtIndexPaths:checkBoxIndexArray];

    }
我得到以下代码的错误

[self.collectionView insertItemsAtIndexPaths:checkBoxIndexArray];
请告诉我,我应该用什么样的值来表示不确定性。

您应该使用
NSIndexPath *indexPath=[Your_Table_Name indexPathForSelectedRow];
[checkBoxIndexArray addObject: indexPath];
[checkBoxIndexArray-addObject:IndexXPath]

您应该使用
[checkBoxIndexArray-addObject:IndexXPath]

正在执行

[checkBoxIndexArray addObject:[NSIndexPath indexPathForRow:indexPath.row inSection:?]]
和这样做是一样的

[checkBoxIndexArray addObject:[NSIndexPath indexPathForRow:indexPath.row inSection:indexPath.section]]
还是这样做

[checkBoxIndexArray添加对象:IndexXPath]

直接添加indexPath,然后根据需要访问行或节值。

[checkBoxIndexArray addObject:[NSIndexPath indexPathForRow:indexPath.row inSection:?]]
和这样做是一样的

[checkBoxIndexArray addObject:[NSIndexPath indexPathForRow:indexPath.row inSection:indexPath.section]]
还是这样做

[checkBoxIndexArray添加对象:IndexXPath]


直接添加indexPath,然后根据需要访问行或节值。

是否尝试将节设置为indexPath.section?另外,如果您已经有了需要保存的indexPath,为什么不直接将您拥有的indexPath对象添加到数组中,而不是创建副本。我尝试设置indexPath.section,但仍然得到了与您得到的错误相同的错误,看起来您是在动态插入或删除单元格。请您详细解释何时何地出现此错误,并显示tableView数据源的代码。请将您尝试的全部代码放在下面。在添加此
indexPath
object的位置,请确保checkBoxIndexArray的数组计数与从numberOfItemAtIndexPath数据源返回的数组计数应相同。出现此错误是因为计数不同。是否尝试将节设置为indexPath.section?另外,如果您已经有了需要保存的indexPath,为什么不直接将您拥有的indexPath对象添加到数组中,而不是创建副本。我尝试设置indexPath.section,但仍然得到了与您得到的错误相同的错误,看起来您是在动态插入或删除单元格。请您详细解释何时何地出现此错误,并显示tableView数据源的代码。请将您尝试的全部代码放在下面。在添加此
indexPath
object的位置,请确保checkBoxIndexArray的数组计数与从numberOfItemAtIndexPath数据源返回的数组计数应相同。您出现此错误是因为计数不相同。我尝试了您提供的两种解决方案,但在您尝试存储indexpath时仍然出现相同的错误?我尝试了您提供的两种解决方案,但在您尝试存储indexpath时仍然出现相同的错误?虽然此代码可以回答问题,提供关于如何和/或为什么解决问题的附加上下文将提高答案的长期价值。虽然此代码可能会回答问题,但提供关于如何和/或为什么解决问题的附加上下文将提高答案的长期价值。