How to convert String to an Int in swift

In swift a String can be converted into a Int in a very easy and safe way. Below example will show how we can easily convert a String to an Int value nil coalescing can also be used if we wish to return a default value in case of a invalid string Hope this helps!!!