         
         let nib = UINib(nibName: "BookViewCell", bundle: nil)
         self.tableView.registerNib(nib, forCellReuseIdentifier: BookViewCell.cellId)
+        
+        self.segmentedControl.selectedSegmentIndex = 0
+        self.segmentedControl.addTarget(self, action: #selector(selectedSegmentChanged), forControlEvents: .ValueChanged)
+        
+        self.navigationItem.titleView = self.segmentedControl
     }
     
     override func viewWillAppear(animated: Bool) {

    }
    
    func getBookAtIndexPath(path: NSIndexPath) -> Book {
        let tagName = self.model.nameOfTagAt(index: path.section)
        return self.model.getBookFromTag(tagName, atIndex: path.row)!
    }
    
    func bookChanged(notif: NSNotification) {


    let model: Library
    var delegate: LibraryViewControllerDelegate?
    var segmentedControl: UISegmentedControl
    
    var areTagsVisibles: Bool {
        get {
            return segmentedControl.selectedSegmentIndex == 0
        }
    }
    
    init(model: Library) {
        self.model = model
        self.segmentedControl = UISegmentedControl(items: ["Tags", "Alphabetical"])
        
        super.init(nibName: nil, bundle: nil)
        
        self.title = "Hacker Books Library"
