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

Convert NsNumber, NSDate to String in iOS Swift

Global LocationManager Singleton class iOS Swift