How to compare two case insensitive strings?

前端 未结 5 365
鱼传尺愫
鱼传尺愫 2021-01-12 17:00

i have 2 string objects containing same string but case is different,now i wanna compare them ignoring the case sensitivity,how to do that??here is the code...



        
5条回答
  •  南笙
    南笙 (楼主)
    2021-01-12 17:38

    A simple one, convert both strings in same case.Here i'm converting it to lower case and then checking it.

    if ([[myString1 lowercaseString] [myString2 lowercaseString]])
    {
     // same
    }
    

提交回复
热议问题