Case-insensitive NSString comparison

前端 未结 4 1518
梦毁少年i
梦毁少年i 2021-02-05 19:35

Using this code I am able to compare string values.

[elementName isEqualToString: @\"Response\"]

But this compares case-sensitively. Is there a

4条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-02-05 20:18

    Here's the code you would need to compare a string without caring about whether it's lowercase or uppercase:

    if ([elementName caseInsensitiveCompare:@"Response"]==NSOrderedSame)
    {
        //  Your "elementName" variable IS "Response", "response", "reSPonse", etc
        //  
    }
    

提交回复
热议问题