1 ios 判断字符串为空和只为空格解决办法 2 3 + (BOOL)isBlankString:(NSString *)string{ 4 5 if (string == nil) { 6 7 returnYES; 8 9 } 10 11 if (string == NULL) { 12 13 returnYES; 14 15 } 16 17 if ([string isKindOfClass:[NSNullclass]]) { 18 19 returnYES; 20 21 } 22 23 if ([[string stringByTrimmingCharactersInSet:[NSCharacterSetwhitespaceAndNewlineCharacterSet]] length]==0) { 24 25 returnYES; 26 27 } 28 29 returnNO; 30 31 }