NSString is empty

前端 未结 8 1865
伪装坚强ぢ
伪装坚强ぢ 2021-01-30 05:45

How do you test if an NSString is empty? or all whitespace or nil? with a single method call?

8条回答
  •  梦毁少年i
    2021-01-30 06:02

    Should be easier:

    if (![[string stringByReplacingOccurencesOfString:@" " withString:@""] length]) { NSLog(@"This string is empty"); }
    

提交回复
热议问题