When a view controller is being loaded it has to obtain a JSON file via a URL. If the internet is down I would like it to cancel loading the view controller. Here is the code so far and I know it is wrong in the catch, but it give you an idea of what I need to do. So overall, should I be using a different override than viewDidLoad() since it "did" load?
override func viewDidLoad() { var jsonText = "" if let url = URL(string: "http://thedomain.com/eventlistjson_r2.asp") { do { jsonText = try String( contentsOf: url,encoding: .utf8) } catch { // contents could not be loaded print(error) super.dismiss(animated: true) } } else { // the URL was bad! print("the URL was bad") } }