Case insensitive comparison NSString

后端 未结 12 1640
滥情空心
滥情空心 2020-12-12 13:15

Can anyone point me to any resources about case insensitive comparison in Objective C? It doesn\'t seem to have an equivalent method to str1.equalsIgnoreCase(str2)

12条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-12 14:00

    On macOS you can simply use -[NSString isCaseInsensitiveLike:], which returns BOOL just like -isEqual:.

    if ([@"Test" isCaseInsensitiveLike: @"test"])
        // Success
    

提交回复
热议问题