是否有任何方法用Objective-C減去兩個或更多NSUInteger值?如何減去兩個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;
}
}];
當我嘗試創建一個新的NSIndexPath與IDX-removedElementsCount,我得到以下錯誤:
HTReorderTableCells.m:231:75: Invalid operands to binary expression ('NSUInteger' (aka 'unsigned int') and 'NSUInteger *' (aka 'unsigned int *'))
我一直在尋求一個解決方案,但我避風港沒有發現任何東西。
你的意思是減號b嗎? – WangYudong
是的,但與NSUInteger – EnriMR
是的,有一種方法。你曾經嘗試失敗過?請顯示一些代碼。 –