所以我收到错误:
致命错误:在解包可选值时意外发现nil
经过一些跟踪和错误之后,我认为它与let ent
有关,请参阅
func newItem(){
let context = self.context
let ent = NSEntityDescription.entityForName("InvoiceList", inManagedObjectContext: context)
print("New data \(ent) ")//outputs: New data nil
let nItem = InvoicesList(entity: ent!, insertIntoManagedObjectContext: context)
似乎是零,但我不能使用ent?如在
let nItem = InvoicesList(entity: ent?, insertIntoManagedObjectContext: context)
那我怎么解决这个问题呢?核心数据实体InvoiceList有属性,但启动时没有值是错误的吗?