首页 > 解决方案 > 选择器“indexPathForRow:inSection:inSection:”没有已知的类方法

问题描述

我似乎在为多维数组创建索引路径时遇到问题。

-(NSIndexPath *)indexPathForObject:(id)object {
    NSIndexPath *indexPath;
    
    for (NSUInteger row = 0; row <self.numberOfRows; row++) {
        for (NSUInteger column = 0; column <self.numberOfColumns; column++) {
            for (NSUInteger stack = 0; stack <self.numberOfStacks; stack++) {
                id arrayObject = self.array[row][column][stack];
                if (arrayObject == object) {
                    indexPath = [NSIndexPath indexPathForRow:row inSection:column inSection:stack];
                }
            }
        }
    }
    return indexPath;
}

我不确定我是否能够像上面那样使用两次“inSection:”。我的 ultimage 目标是确定 3 维空间中的值。谢谢!

标签: arraysobjective-cxcodemultidimensional-array

解决方案


推荐阅读