How can I test an NSString for being nil?

前端 未结 8 1815
借酒劲吻你
借酒劲吻你 2020-12-09 07:12

Can I simply use

if(myString == nil)

For some reason a string that I know is null, is failing this statement.

8条回答
  •  一整个雨季
    2020-12-09 07:26

    you may check your getting string using this

       if(myString==(id) [NSNull null] || [myString length]==0 || [myString isEqualToString:@""])
        {
         //String is null or bad response
        }
    

提交回复
热议问题