有没有办法用Objective-C减去两个或更多NSUInteger值?
这是我的代码
__block NSUInteger *removedElementsCount = 0;
__block BOOL lastIsSuperElement = NO;
// Get the elements not collapsed
[_elements enumerateObjectsUsingBlock:^(id __nonnull obj, NSUInteger idx, BOOL * __nonnull stop) {
if (_isHidingSubElementsBlock(obj)){
//_collapseSubCellsAtIndexPathBlock(idx+_elementsOffset);
[elementToRemove addObject:(Task *)obj];
lastIsSuperElement = YES;
[indexPathToRemove addObject:[NSIndexPath indexPathForRow:(idx-removedElementsCount) inSection:0]];
removedElementsCount = 0;
} else if (lastIsSuperElement){
removedElementsCount++;
lastIsSuperElement = NO;
}
}];
当我尝试使用idx-removedElementsCount创建新的NSIndexPath时,出现以下错误:
HTReorderTableCells.m:231:75: Invalid operands to binary expression ('NSUInteger' (aka 'unsigned int') and 'NSUInteger *' (aka 'unsigned int *'))
我找了一个解决方案,但我没找到任何东西。
答案 0 :(得分:-2)
removedElementsCount
不是NSUInteger
,而是NSUInteger*
(指向整数的指针)。
尝试在减法之前更改表达式以取消引用指针。
idx - (*removedElementsCount)