iOS compare button title to string

后端 未结 4 1857
渐次进展
渐次进展 2020-12-11 18:18

I\'m just learning how to code so thanks for your patience on this simple question.

Here\'s my code:

- (IBAction)buttonWasPressed:(id)sender {  
            


        
4条回答
  •  误落风尘
    2020-12-11 18:48

    The better way to compare string is:

    NSString *string1 = ;
    NSString *string2 = ;
    
    if ([string1 caseInsensitiveCompare:string2] == NSOrderedSame) {
        //strings are same
    } else {
        //strings are not same
    }
    

提交回复
热议问题