Create a web link to be valid HTTP or HTTPS iOS swift

Solution:

If you had a url with website name but it does not contain any HTTP or HTTPS.If you faced any problem when connect to that website because of that then follow the below code.


 if urlString.hasPrefix("https://") || urlString.hasPrefix("http://"){
            }else {
                urlString = "http://\(urlString)"
            }



The above code will append the string with prefix.So no issues will come.Enjoy coding.

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