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.


            if let url = URL(string: urlString) {


                        UIApplication.shared.open(url, options: [:], completionHandler: { (success) in

                            print("Open url : \(success)")
                        })
}

Comments

Popular posts from this blog

Invalid bundle error while upload the app to the app Store

Saved Image in document directory and save path in coredata not able to fetch the image file iOS swift