             randomString += String(newCharacter)
         }
         
+        /* managed objects must be inserted in a transaction (not the main thread).
+           An implicit commit finalizes the transaction after it is finished.  
+        
+           You can call Cd.cancelImplicitCommit() to disable this implicit commit,
+           which is useful if you are canceling any changes made during the transaction.
+        
+           You can call Cd.commit() anytime to explicitly save any changes in the transaction
+           up to the call. */
         Cd.transact {
             let newItem = Cd.create(ExampleItem.self)
             newItem.name = randomString

        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

    override func viewDidLoad() {
        super.viewDidLoad()
        self.view.backgroundColor = UIColor.whiteColor()
        self.title = "Cadmium Example"
        
        self.navigationItem.leftBarButtonItem  = UIBarButtonItem(title: "Add",  style: .Plain, target: self, action: "handleAdd:")
        self.navigationItem.rightBarButtonItem = UIBarButtonItem(title: "Edit", style: .Plain, target: self, action: "handleEdit:")
    
        /* Create a fetched results controller that will list all of our example items  (sorted by name) */
        fetchedResultsController = CdFetchedResultsController(
            fetchRequest: Cd.objects(ExampleItem.self).sorted("name").nsFetchRequest,
            sectionNameKeyPath: nil,
            cacheName: nil)
        
        /* Using the delegate automation allows Cadmium to automatically update the UITableView
           data source when changes occur to the underlying model. */
        fetchedResultsController?.automateDelegation(forTable: self.tableView)
        
        /* Call performFetch to initiate the controller */
        try! fetchedResultsController?.performFetch()
        
    }
    
    /* Adds an ExampleItem with a random 10-character name */
    func handleAdd(button: UIBarButtonItem) {
        let allowedChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
        let allowedCharsCount = UInt32(allowedChars.characters.count)
