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.
The above code will append the string with prefix.So no issues will come.Enjoy coding.
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
Post a Comment