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

前端 未结 2 1505
悲哀的现实
悲哀的现实 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:15

    There are probably other characters in the string.

    Use

    [strResult stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
    

提交回复
热议问题