Sfoglia il codice sorgente

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

John Pope 10 anni fa
parent
commit
2bffaf1b8e
1 ha cambiato i file con 4 aggiunte e 2 eliminazioni
  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 {