I'm learning Swift and I'm finding some issues to learn it also because my background is as .NET developer and I'm thinking in a different way.
So, 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
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()
}
}
}
}
Also, when I use the instance of the ToDo Core Data and I perform a boxing, I get another kind of errors.
Type of expression is ambiguous without more context
Do I have to import a library to access the Core Data? What did I miss in this code?