Check the TextFIeld is empty in iOS swift || TextField character count is empty or not without spaces

Solution:

If textfield is empty if you check with that it will return false if you had typed the spaces.So you can use the below function to validate the textfield with character count.



        let trimmed = textFld.text.trimmingCharacters(in: .whitespacesAndNewlines)
        if trimmed == ""{
//show the error alert
        }

Comments

Popular posts from this blog

Invalid bundle error while upload the app to the app Store

Convert NsNumber, NSDate to String in iOS Swift

Global LocationManager Singleton class iOS Swift