I get the error message "use of unresolved identifier" Contacts "(this is the name that I named Entity in my" fileName.xcdatamodeld ").
import UIKit
import CoreData
class ViewController: UIViewController {
let managedObjectContext = (UIApplication.shared.delegate as! AppDelegate).persistentContainer.viewContext
override func viewDidLoad() {
super.viewDidLoad()
}
@IBAction func SaveContact(_ sender: Any) {
let entityDescription = NSEntityDescription.entity(forEntityName: "Contacts",in: managedObjectContext)
let contact = Contacts(entity: entityDescription!,insertInto: managedObjectContext)
}
@IBAction func Findcontact(_ sender: Any) {
}
}
source
share