-->

if NSString does not equal function?

2020-07-09 06:52发布

问题:

I have searched all over the place for this, including apple's docs on NSString (maybe I didn't see?) but I am trying to find a method in xCode for checking wether a NSString does not equal to something. Much like

if (myNSSting = @"text" {...

except specifically I want to check if it does not equal to 'text'.

回答1:

 if(![myNSString isEqualToString:@"text"])


回答2:

For case insensitive compare we can handle by:

 if( [@"Some String" caseInsensitiveCompare:@"some string"] == NSOrderedSame ) {
      // strings are equal except for possibly case
    }