【问题标题】:IOS/Objective-C: Conflicting return type in implementation errorIOS/Objective-C:实现错误中的返回类型冲突
【发布时间】:2018-09-05 03:51:12
【问题描述】:

任何人都可以建议为什么以下会在实现错误 myStatus 级别 void 与 int 中发出冲突返回类型的警告,这是什么意思,以及如何解决它?

提前感谢您的任何建议。

-(int) myStatusLevel: (int)numpoints {
    //calculates status from points and saves in default.
    int status;
    if (numpoints>=20&&numpoints<=99) {
        status = 1;
    }
    else if (numpoints>=100&&numpoints<=499) {
        status = 2;
    }
    else if (numpoints>=500&&numpoints<=999) {
        status = 3;
    }
    else if (numpoints>=1000&&numpoints<=1999) {
        status = 4;
    }
    else if (numpoints>=2000) {
        status = 5;
    }
    else {
        status = 0;
    }

    return status;
}

【问题讨论】:

  • @Rob 就是这样。谢谢。如何简化使用该链接?
  • 哦。明白了。实际上,我最初是按照这些思路进行的,但添加了明确的上限和下限,因为我认为这可能会导致错误。很高兴确认不需要它们,因为代码更简单。

标签: ios objective-c int


【解决方案1】:

您可能在您的@interface 中使用void 定义了myStatusLevel,而不是您在此处与我们共享的方法签名。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-04-05
    • 1970-01-01
    • 2014-03-10
    • 2013-04-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多