I have some code here and when I call testFunc()
it crashes on line value = NSObject()
with error EXC_BAD_ACCESS (code=EXC_I386_GPFLT).
I figured out, that removing private
from class A init(_ object: Any?)
fixes problem. Why does it happens?
class A {
var object: Any?
convenience init() {
self.init(nil)
}
private init(_ object: Any?) {
self.object = object
}
}
class B: A {
var value: Any?
func test() {
value = NSObject()
}
}
func testFunc() {
let b = B()
b.test()
}