小编Vla*_*iak的帖子

Swift 2.0转换问题NSFetchedResultsController didChangeObject

在Swift 2.0中转换后我无法解决问题:

"Objective-C方法"控制器:didChangeObject:atIndexPath:forChangeType:newIndexPath:'由方法'controller(:didChangeObject:atIndexPath:forChangeType:newIndexPath :)提供'与可选需求方法'controller(:didChangeObject:atIndexPath:forChangeType:newIndexPath)冲突:)'在协议'NSFetchedResultsControllerDelegate'"

请帮我.谢谢你的进步

func controllerWillChangeContent(controller: NSFetchedResultsController) {
    tableView.beginUpdates()
}

func controller(controller: NSFetchedResultsController, didChangeObject anObject: NSManagedObject, atIndexPath indexPath: NSIndexPath?, forChangeType type: NSFetchedResultsChangeType, newIndexPath: NSIndexPath?) {

    // the issue is here

    switch type {

    case NSFetchedResultsChangeType.Insert:
        if let newIndex = newIndexPath {
            tableView.insertRowsAtIndexPaths([newIndex], withRowAnimation: UITableViewRowAnimation.Automatic)
        }

    case NSFetchedResultsChangeType.Delete:
        if let index = indexPath {
            tableView.deleteRowsAtIndexPaths([index], withRowAnimation: UITableViewRowAnimation.Automatic)
        }
    }
}

func controllerDidChangeContent(controller: NSFetchedResultsController) {
    tableView.endUpdates()
}
Run Code Online (Sandbox Code Playgroud)

core-data nsfetchedresultscontroller swift

3
推荐指数
1
解决办法
652
查看次数