[英]How to create and store managed objects containing the data using Swift 3.0 in Xcode 8.2
I'm getting an error 'use of unresolved identifier 'Contacts' '( it's the name i have given as Entity name in my 'fileName.xcdatamodeld' ). 我收到错误'使用未解析的标识符'Contacts''(这是我在'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) // Error: Use of unresolved identifier 'Contacts'
}
@IBAction func Findcontact(_ sender: Any) {
}
}
This is how you configure the Core Data codegen in Xcode 8: 这是您在Xcode 8中配置Core Data codegen的方法:
You have 3 options: 你有3个选择:
I think they are pretty self-explanatory. 我认为它们非常明显。 Anyway what you probably want here is Class Definition.
无论如何,你在这里想要的是类定义。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.