简体   繁体   English

使用 Core Data 在 UITableViewController 中保存重新排序的单元格

[英]Saving reordering cells in UITableViewController with Core Data

I'm looking for simple implementation of saving reordering cells in UITableViewController with Core Data.我正在寻找使用 Core Data 在UITableViewController中保存重新排序单元格的简单实现。

Now I'm using the default function for reorder cells:现在我使用默认的 function 重新排序单元格:

var timers: [Timers] = []

    override func tableView(_ tableView: UITableView, moveRowAt sourceIndexPath: IndexPath, to destinationIndexPath: IndexPath) {

    let movedObject = timers[sourceIndexPath.row]
    timers.remove(at: sourceIndexPath.row)
    timers.insert(movedObject, at: destinationIndexPath.row)


    }

How I can implement Core Data for saving cell ordering feature?如何实现 Core Data 以保存单元格排序功能?

You need to re-save the array again every leave of that vc say inside deinit每次离开该 vc 时,您都需要在deinit中重新保存数组

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM