         // Dispose of any resources that can be recreated.
     }
     
-    func handleAdd(button: UIButton) {
+    func handleAdd(button: UIBarButtonItem) {
         let allowedChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
         let allowedCharsCount = UInt32(allowedChars.characters.count)
         var randomString = ""

        Cd.transact {
            let newItem = Cd.create(ExampleItem.self)
            newItem.name = randomString
            try! Cd.commit()
        }
    }
    

    
    override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
        tableView.deselectRowAtIndexPath(indexPath, animated: true)
        guard let item = fetchedResultsController?.objectAtIndexPath(indexPath) as? ExampleItem else {
            return
        }
        
        Cd.transact {
            guard let txItem = Cd.useInCurrentContext(item) else {
                return
            }
            
            txItem.numberTaps += 1
        }
        
    }
    
    // MARK: Editing
    
    override func tableView(tableView: UITableView, canEditRowAtIndexPath indexPath: NSIndexPath) -> Bool {
        return true
    }
    
    override func tableView(tableView: UITableView, editingStyleForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCellEditingStyle {
        return .Delete
    }
    
    override func tableView(tableView: UITableView, commitEditingStyle editingStyle: UITableViewCellEditingStyle, forRowAtIndexPath indexPath: NSIndexPath) {
        guard let item = fetchedResultsController?.objectAtIndexPath(indexPath) as? ExampleItem else {
            return
        }
        
        Cd.transact {
            guard let txItem = Cd.useInCurrentContext(item) else {
                return
            }
            
            Cd.delete(txItem)
        }
    }
}
