Search code examples
objective-cbooleanternary

Objective-C : Implicit declaration of function 'isEmptyString' is invalid in c99


Following is the mentioned function :-

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

While using this function as follows:-

BOOL d = isEmptyString(@"data");

raises afore mentioned dont know why. Can someone explain as to what am i doing wrong.


Solution

  • You declared the function in objective-c but you are calling it as if it was a c function.

    You should either change the declaration or change the way you call it.

    You should call it this way (assuming you are in the same .m file)

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