Open an URL in safari iOS swift || validate URL and open iOS swift
Solution:
It will validate the url if it was null then it will not open the url.Otherwise it will be opened.
If let condition was used to avoid the crash if the url is not valid.
It will validate the url if it was null then it will not open the url.Otherwise it will be opened.
If let condition was used to avoid the crash if the url is not valid.
if let url = URL(string: urlString) {
UIApplication.shared.open(url, options: [:], completionHandler: { (success) in
print("Open url : \(success)")
})
}
Comments
Post a Comment