0
我有這段代碼,每當我運行的應用程序,它給了我EXC_BAD_ACCESS。 我在XCode的終端打印self.state和newValue.rawValue的值,他們有價值,但我不明白爲什麼我得到「EXC_BAD_ACCESS」錯誤和「CoreData:警告:無法加載爲實體類命名未找到,使用默認的NSManagedObject「。我收到這個錯誤時,我做以下setter的奇怪問題
d.change = .n //d is just instance of class from where state comes
什麼可以是一個原因?
var change: A {
get { return (A(rawValue: self.state) ?? .none)! }
set { self.state = newValue.rawValue }
}
enum A: Int16 {
case a = 1
case b = 2
case c = 3
case n = 90
}
國家是階級的屬性,從NSManagedObject
繼承@NSManaged var state: Int16