Determining that the nsstring is null is a problem that almost every developer will encounter. The following method is the first thing that most people flash their brains.
If ([yourtextstring isequaltostring: @ ""])
However, it is a pity that such judgments often fail, resulting in many inexplicable bugs. For example, if you use this method to determine whether uitextfield is empty, a problem may occur.
[Yourtextfield. Text isw.tostring: @ ""]
The above line will also be "no" if the user does not make any input. What is the reason?
The answer is actually very simple. The value of yourtextfield. text after initial creation is nil, and nil is not equal to @ ", so the above Code should be changed:
[Yourtextfield. Text is1_tostring: @ ""] | yourtextfield. Text = Nil
Although the above line of code can work normally, it is a bit depressing to write such a line of code every time. In fact, there is a simple and clear work ing method that I suggest you use:
Yourtextfield. Text. Length = 0
Address: http://www.cnblogs.com/hellocby/archive/2012/12/20/2826318.html