gpt4 book ai didi

ios - 我在 appDelegate 中收到错误?

转载 作者:行者123 更新时间:2023-11-30 14:12:06 25 4
gpt4 key购买 nike

当我尝试将待办事项列表应用程序的代码从 preCoreData 更改为 coreData 时。

我收到此错误:

'NSInvalidArgumentException',原因:'executeFetchRequest:错误:获取请求必须具有实体。'

this is the preCoreData app link

this is the CoreData app link

最佳答案

我的代码中缺少实体名称

我的代码有错误

 func taskFetchRequest() -> NSFetchRequest {

let fetchRequest = NSFetchRequest()

    let sortDescriptor = NSSortDescriptor(key: "date", ascending: true)
let completedDescriptor = NSSortDescriptor(key: "completed", ascending: true)
fetchRequest.sortDescriptors = [completedDescriptor, sortDescriptor]

return fetchRequest
}

我的代码没有错误

 func taskFetchRequest() -> NSFetchRequest {

let fetchRequest = NSFetchRequest(entityName: "TaskModel")

    let sortDescriptor = NSSortDescriptor(key: "date", ascending: true)
let completedDescriptor = NSSortDescriptor(key: "completed", ascending: true)
fetchRequest.sortDescriptors = [completedDescriptor, sortDescriptor]

return fetchRequest
}

关于ios - 我在 appDelegate 中收到错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31661291/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com