Topic starter
22/08/2021 11:09 am
I'm following a book and I'm trying to add a Core Data to my project. You have the full source code on GitHub.
In Xcode a pass a new Entity for Core Data called ToDoCR, very basic.
When I try to use the ToDoCR entity, I get some errors from Xcode.
Cannot find type 'ToDoCD' in scope
var todoCDs: [ToDoCD] = []
override func viewDidLoad() {
super.viewDidLoad()
}
func getToDos() {
if let context = (UIApplication.shared.delegate as?
AppDelegate)?.persistentContainer.viewContext {
if let toDosFromCoreData = try? context.fetch(ToDoCD.fetchRequest()) {
if let toDos = toDosFromCoreData as? [ToDoCD] {
todoCDs = toDos
tableView.reloadData()
}
}
}
}
Do I have to import a library to access the Core Data? What did I miss in this code?
Topic starter
05/09/2021 4:28 pm
For same reasons, this seems a common problem with XCode. To fix the issue, just close and reopen XCode and then open your project. The project will be ok.