浏览代码

Fix crash in Reachability example. (#3000)

The reachability is not assigned which can cause app crash when
tap on the Reachability Status row
Ethan 6 年之前
父节点
当前提交
b03798fb30
共有 1 个文件被更改,包括 2 次插入1 次删除
  1. 2 1
      Example/Source/MasterViewController.swift

+ 2 - 1
Example/Source/MasterViewController.swift

@@ -43,6 +43,7 @@ class MasterViewController: UITableViewController {
         navigationItem.titleView = titleImageView
         clearsSelectionOnViewWillAppear = true
 
+        reachability = NetworkReachabilityManager.default
         monitorReachability()
     }
 
@@ -94,7 +95,7 @@ class MasterViewController: UITableViewController {
     // MARK: - Private - Reachability
 
     private func monitorReachability() {
-        NetworkReachabilityManager.default?.startListening { status in
+        reachability.startListening { status in
             print("Reachability Status Changed: \(status)")
         }
     }