Crash when i try to add a to-do

reason: ‘attempt to insert row 0 into section 0, but there are only 0 rows in section 0 after the update’

`func itemDetailViewController(controller: ItemDetailViewController, didFinishAddItem item: ChecklistItem) {
let newRowIndex = checklist.items.count

    items.append(item)
    
    let indexPath = NSIndexPath(forRow: newRowIndex, inSection: 0)//crash in this line 
    let indexPaths = [indexPath]
    tableView.insertRowsAtIndexPaths(indexPaths, withRowAnimation: .Automatic)
    
    dismissViewControllerAnimated(true, completion: nil)
}`

Double-check your code.
You reference checklist.items for your count, but reference items when you append your new item.

yeah , Thanks . I found it