ios - 如何减去两个NSUInteger变量?

标签 ios objective-c subtraction

有什么方法可以用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 *'))

我一直在寻找解决方案,但没有发现任何东西。

最佳答案

将NSInteger用于您的解决方案。

NSUInteger value1 = 5;
NSUInteger value2 = 3;
NSInteger subs = value1 - value2;

在您的代码中修复removedElementsCount的声明(删除*)

关于ios - 如何减去两个NSUInteger变量?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32479443/

相关文章:

jquery - 如何对字符串进行减法

ios - 按下时需要放大图像。我该怎么做?

ios - 从其 UIViewController 中的按钮关闭 UIPopoverController

ios - 在代码中使用 Regular 以外的 iOS 系统字体样式

ios - __has_include 检查是否存在针对 swift 的类?

mysql - 对于每个唯一的partner_ID,彼此减去2个数据库行?数据库管理系统

ios - 收集 View IOS 中的 UILABEL 换行符

iPhone:向用户显示简单警告/警报消息的内置方式

objective-c - iOS从web读取Json并显示到tableView

java - 通过添加/减去相应的值来合并 map