0

无论我在 中输入什么值sectionNameKeyPath: "value",获取的对象都会按照它们在数据库中保存的顺序返回。部分的数量是正确的,但是无论我是按部分查看获取的对象fetchedResultsController.sections还是fetchedResultsController.object(at: indexPath)得到相同的结果。

这是在 UITableViewController

lazy var fetchedResultsController: NSFetchedResultsController<Dice> = {
    let fetchRequest: NSFetchRequest<Dice> = Dice.fetchRequest()

    fetchRequest.sortDescriptors = [NSSortDescriptor(key: "createdAt", ascending: false)]

    let appDelegate = UIApplication.shared.delegate as! AppDelegate
    let context = appDelegate.persistentContainer.viewContext

    // Doesn't matter what I set in the "sectionNameKeyPath" value
    let fetchedResultsController = NSFetchedResultsController(fetchRequest: fetchRequest, managedObjectContext: context, sectionNameKeyPath: "set.identifier", cacheName: nil)

    fetchedResultsController.delegate = self

    return fetchedResultsController
}()

有没有其他人看过这个?

4

0 回答 0