I am trying to add a stored property to an NSBezierPath by subclassing it. However the following code crashes Playground:
import Cocoa
class MyNSBezierPath: NSBezierPath {
private var someProperty: Bool
override init() {
someProperty = false
super.init()
}
required init?(coder aDecoder: NSCoder) {
self.someProperty = false
super.init(coder: aDecoder)
}
}
// the following line causes the Playground to fully crash
let somePath = MyNSBezierPath()
The Playground error (below) seems to indicate a problem with NSCoder
but I thought that just passing the call through to the superclass like this would be OK. What am I doing wrong?
UNCAUGHT EXCEPTION (NSInvalidUnarchiveOperationException):
*** - [NSKeyedUnarchiver decodeObjectForKey:]: cannot decode object of class
(__lldb_expr_22.MyNSBezierPath) for key (root);
the class may be defined in source code or a library that is not linked
UserInfo: { "__NSCoderInternalErrorCode" = 4864;}
Hints: None