How can I test an NSString for being nil?

前端 未结 8 1831
借酒劲吻你
借酒劲吻你 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:40

    I encountered this problem today. Despite assigning a string to be nil: NSString *str = nil;, the test if (str == nil) returned FALSE! Changing the test to if (!str) worked, however.

提交回复
热议问题