怎么判斷字符串中的字符為空 如何徹底判斷用戶輸入的字符串是否為空?
如何徹底判斷用戶輸入的字符串是否為空?(BOOL)isstring:(ns string *)str {//1.長度等于0,strnil相同,直接判定為null。if(字符串長度為0)返回YES//2
如何徹底判斷用戶輸入的字符串是否為空?
(BOOL)isstring:(ns string *)str {
//1.長度等于0,strnil相同,直接判定為null。
if(字符串長度為0)返回YES
//2.表示長度大于0,所以首先要對用戶輸入的字符中的空格和換行符進行修整,然后才能判斷長度是否為0。
ns string * trimStr[str stringbytrimmingcharact:[ns characters et whitespace and newline characters et]]
If(trimStr.length 0) {//空格被切掉,換行后長度為0。
返回是
} else {//剪去空格換行后長度不為0。
退貨編號
}