【问题标题】:Objective-C : Implicit declaration of function 'isEmptyString' is invalid in c99Objective-C:函数'isEmptyString'的隐式声明在c99中无效
【发布时间】:2017-08-29 05:53:29
【问题描述】:

以下是提到的功能:-

-(BOOL) isEmptyString :(NSString*) string {
    if([string isEqualToString:@""] || [string isKindOfClass:[NSNull class]]) {
        return true;
    }
    return false;
}

使用此功能时如下:-

BOOL d = isEmptyString(@"data");

提出上述不知道为什么。有人可以解释一下我做错了什么。

【问题讨论】:

    标签: objective-c boolean ternary


    【解决方案1】:

    您在 Objective-c 中声明了该函数,但您调用它时就好像它是一个 c 函数。

    您应该更改声明或更改调用方式。

    你应该这样称呼它(假设你在同一个 .m 文件中)

    BOOL d = [self isEmptyString:@"data"]

    【讨论】:

    • 谢谢阿里斯。实际上我更喜欢 swift 并且在 Objective-c 中没有我知道的默认运算符。
    • 没问题! “默认运算符”是什么意思?
    • ??在 swift 中是默认操作符
    • 嗯,明白了。
    • 那么在objective-c中是否有类似的默认设置?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-07-09
    • 1970-01-01
    • 2013-11-28
    • 2018-10-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多