5
मुझे आश्चर्य है कि अगर मैं एक यूटक्स्टव्यू खाली है तो मैं उचित जांच कैसे करूं।स्विफ्ट चेक यदि टेक्स्टव्यू खाली है
if let descText = myTextView.text {
if descText.isEmpty {
descErrorLabel.isHidden = false
} else {
descErrorLabel.isHidden = true
}
}
यह यह पर्याप्त एक खाली TextView भेजने से उपयोगकर्ता को रोकने के लिए या मैं कुछ की तरह भी व्हाइटस्पेस की जांच करना चाहिए,:
stringByTrimmingCharactersInSet(NSCharacterSet.whitespaceAndNewlineCharacterSet()).isEmpty
अभी मैं एक मान्यता fucntion जो जांच करता है
बाद में कोई अच्छा है। –
http://stackoverflow.com/questions/33036458/how-to-check-uitextfield-is-not-blank-in-swift-2-0-is-there-better-way-to-count/33036724 –
@ EricAya – user2636197