how to compare a string from url to NSutf8stringencoding return 1 or 0 with normal string @“1”

前端 未结 2 1509
悲哀的现实
悲哀的现实 2021-01-22 04:53

I need to compare a string from an url using NSutf8stringencoding in order to return 1 or 0, but it always returns 0 even if the string has value 1.



        
2条回答
  •  情话喂你
    2021-01-22 05:11

    Try the following - there could be additional whitespace characters in the strResult (like carriage returns):

    if ([strResult rangeOfString:@"1"].length > 0) {
        // Do something...
    }
    

提交回复
热议问题