Commit ae4d7eb1 authored by Steven杜宇's avatar Steven杜宇

// 字符串判空

parent 12eed2c0
......@@ -233,3 +233,19 @@ extension String {
return NSRange(range, in: self)
}
}
extension String {
public func isYHEmpty() -> Bool {
let realStr = self.getRealString()
return realStr.count <= 0
}
public func getRealString() -> String {
if self.count <= 0 { return "" }
// 去除两端连续空格
var targetStr = self.trimmingCharacters(in: .whitespaces)
// 去除所有换行符
targetStr = targetStr.replacingOccurrences(of: "\n", with: "")
return targetStr
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment