     // MARK: - Table View
 
     override func numberOfSectionsInTableView(tableView: UITableView) -> Int {
-        return 1
+        return movies.count
     }
 
     override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
-        return movies.count
+        let entry = movies[section]
+        return entry.1.count
     }
 
     override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
         let cell = tableView.dequeueReusableCellWithIdentifier("Cell", forIndexPath: indexPath) as! UITableViewCell
 
-        let object = movies[indexPath.row]
-        cell.textLabel!.text = object
+        let entry = movies[indexPath.section]
+        let movie = entry.1[indexPath.row]
+        cell.textLabel!.text = movie
         return cell
     }
     
     override func tableView(tableView: UITableView, titleForHeaderInSection section: Int) -> String? {
-        return "Available disk space: \(diskSpaceAvailable)"
+        let entry = movies[section]
+        let title = entry.0
+        return String(title)
+    }
+    
+    override func tableView(tableView: UITableView, titleForFooterInSection section: Int) -> String? {
+        if section == movies.count - 1 {
+            return "Disk space available: \(diskSpaceAvailable)"
+        }
+        return nil
+    }
+    
+    override func sectionIndexTitlesForTableView(tableView: UITableView) -> [AnyObject]! {
+        return movies.map { entry -> String in
+            String(entry.0)
+        }
     }
 }


import UIKit


class MasterViewController: UITableViewController {

    var detailViewController: DetailViewController? = nil
    var selectedMovieTitle : String? = nil
    var movies = [String]()
    var diskSpaceAvailable = ""

    override func awakeFromNib() {

    func movieListLoaded(notification: NSNotification) {
        if let userInfo = notification.userInfo,
            let remoteMovies = userInfo["data"] as? [String] {
                movies = buildIndex(remoteMovies)
                tableView.reloadData()
        }
    }
