vendredi 18 décembre 2015

Why is this consecutive not allowed

I am trying to follow this appcoda GoogleMaps tutorial and converting to swift 2. I am really new to swift and having trouble understanding.

do {
   let dictionary = try NSJSONSerialization.JSONObjectWithData(geocodingResultsData!, options: NSJSONReadingOptions.MutableContainers) as? NSDictionary

   } catch let error as NSError {

      print("Error")
      completionHandler(status: "", success: false)

   }; else {
      // Get the response status.
      let status = dictionary["status"] as String

      if status == "OK" {
        let allResults = dictionary["results"] as Array<Dictionary<NSObject, AnyObject>>
        self.lookupAddressResults = allResults[0]

I am getting the error before "else" where it first recommended a ";" because of consecutive statement but then it errors in the same place "expected expression". I swear I have done this before without errors. I am having trouble understanding why. Is it something to do with a poor set up of try, catch, do? Any insight appreciated, thanks.

Aucun commentaire:

Enregistrer un commentaire