How to check if an string is empty in Swift

How to check if an string is empty in Swift

In this post we will give you information about How to check if an string is empty in Swift. Hear we will give you detail about How to check if an string is empty in SwiftAnd how to use it also give you demo for it if it is necessary.

we are going to learn about how to check if the string is empty or not in Swift.

Checking string is empty

To check if a given string is empty or not, we can use the built-in isEmpty property in Swift.

The isEmpty property returns true if an string is empty; otherwise returns false.

Here is an example:

var place = ""print(place.isEmpty)

Output:

true

Similarly, we can also check it using the count property in Swift.

var place = ""if(place.count == 0){    print("string is empty")}else{    print("string is not empty")}

Output:

"string is empty"

Hope this code and post will helped you for implement How to check if an string is empty in Swift. if you need any help or any feedback give it in comment section or you have good idea about this post you can give it comment section. Your comment will help us for help you more and improve us. we will give you this type of more interesting post in featured also so, For more interesting post and code Keep reading our blogs

For More Info See :: laravel And github

We're accepting well-written guest posts and this is a great opportunity to collaborate : Contact US