iOS compare button title to string

后端 未结 4 1851
渐次进展
渐次进展 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 19:08

    Use -isEqualToString method:

    if ([buttonName isEqualToString:@"Button 1"])
       ...
    

    using == you compare ponters, not the actual string values they contain

提交回复
热议问题