 
 extension ContactsViewController: UITableViewDataSource, UITableViewDelegate {
 
+    enum Section: Int {
+        case Local
+        case Online
+    }
+
+    func numberOfSectionsInTableView(tableView: UITableView) -> Int {
+        return 2
+    }
+
     func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
-        return searchControllerIsActive ? (filteredFriends?.count ?? 0) : friends.count
+        guard let section = Section(rawValue: section) else {
+            return 0
+        }
+
+        switch section {
+        case .Local:
+            return searchControllerIsActive ? (filteredFriends?.count ?? 0) : friends.count
+        case .Online:
+            return 0
+        }
     }
 
     private func friendAtIndexPath(indexPath: NSIndexPath) -> User? {


        // 超过一定人数才显示搜索框

        if friends.count > Ruler.iPhoneVertical(6, 8, 10, 12).value {

            let searchController = UISearchController(searchResultsController: nil)
            searchController.delegate = self

            tableView.deselectRowAtIndexPath(indexPath, animated: true)
        }

        guard let section = Section(rawValue: indexPath.section) else {
            return
        }

        switch section {

        case .Local:

            if let friend = friendAtIndexPath(indexPath) {

                searchController?.active = false

                performSegueWithIdentifier("showProfile", sender: friend)
            }

        case .Online:
            break
        }
   }
}
