Procházet zdrojové kódy

Added an optional bind around the response to safely extract headers.

John Pope před 10 roky
rodič
revize
2bffaf1b8e
1 změnil soubory, kde provedl 4 přidání a 2 odebrání
  1. 4 2
      Example/DetailViewController.swift

+ 4 - 2
Example/DetailViewController.swift

@@ -79,8 +79,10 @@ class DetailViewController: UITableViewController {
             let end = CACurrentMediaTime()
             self.elapsedTime = end - start
 
-            for (field, value) in response!.allHeaderFields {
-                self.headers["\(field)"] = "\(value)"
+            if let response = response {
+                for (field, value) in response.allHeaderFields {
+                    self.headers["\(field)"] = "\(value)"
+                }
             }
 
             if let segueIdentifier = self.segueIdentifier {