I get Swift Compiler Error - Command failed due to signal: Segmentation fault: 11" whenever I try override a function of a subclass that inherits from NSObject that is declared within a function.
I've tried it with different classes and functions, I get the error for all of them.
- I will only get the error if I am overriding a function or
- If I remove the NSObject, it works and I do not get the error.
Anybody know why this is and why inheriting from NSObject makes a difference?
Example:
class ParentClass: NSObject {
func returnFooString() -> String {
return "foo"
}
}
//This Fails
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
class childClass: ParentClass {
override func returnFooString() -> String {
return "bar"
}
}
}
}
//This Passes
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
class childClass: ParentClass {
func returnBarString() -> String {
return "bar"
}
}
}
}
Overriding the returnFooString function will only pass if ParentClass does not inherit from NSObject
This seems like it was a bug in the older versions of Swift. I have tested again in Swift 2.0 and it is now fixed