Purushothaman
Purushothaman

Reputation: 358

UITextView check whether text field is empty or not in Objective-C

i have UITextView which is inside the tableview cell, and when i click on the "NO" option , the cell will expand , i need to pass the both text which is entered in the textview and image which is uploaded here,

But the problem is am not able to validate the textview, whether it is empty or not,

i should check whether it is empty or not, and if it is empty is need to alert the message. enter image description here

Upvotes: 1

Views: 1125

Answers (1)

Michael Dautermann
Michael Dautermann

Reputation: 89509

Set the table view cell containing your text as a custom table view cell. When you do that, you can connect your UITextView to an outlet.

Once you do that, it's easy to check by simply looking at the length of the .text property for that outlet.

e.g. something like:

(for Swift):

if myTextView.text.characters.count > 0
{
   // there is something in here
}

Upvotes: 3

Related Questions