I'm running into an error where I'm not certain if it's a limitation of the Swift language, or a bug. Here's the most basic premise:
class GenericClass<T> : NSObject {
var inputValue: T
init(value: T) {
self.inputValue = value
super.init()
}
}
class SubClass : GenericClass<String> {
override init(value: String) {
super.init(value: value)
}
}
var test = GenericClass(value: "test") //Succeeds
var test2 = SubClass(value: "test2") //Fails with EXC_BAD_ACCESS
I'm getting no compiler warnings here, but the Subclass refuses to instantiate. I have a more complicated goal within subclassing specific contexts of a generic, but this basic issue above is what I boiled it down to.
Interestingly, if I remove the NSObject inheritance on the GenericClass (and the super.init() from the generic's init method), this setup works without issue, so I'm thinking it must have something to do with the fact that I'm inheriting from NSObject. My full implementation MUST inherit from an NSOperation (I'm basically making custom NSOperation classes with a generic superclass), so inheriting from NSObject(i.e. NSOperation) is not optional for me.
It's bothersome that there are no compiler errors and I'm getting something as nasty as a EXC_BAD_ACCESS. It makes me think that maybe this is supposed to work, but isn't currently. I know they only recently began supporting the subclassing of generic classes in Swift. I'm running the latest xCode beta 6.
Any insight appreciated!