The following code runs fine in the iOS Simulator, but causes an EXC_BAD_ACCESS exception on the device.
Is this a bug in Swift or am I just doing something weird here?
What doesn't work:
class Foo: NSObject {
class var name: String {
return "A foo"
}
}
struct FooWrapper<T: Foo> {
var fooName: String
init(foo: T) {
fooName = foo.dynamicType.name
}
}
var foo = Foo()
var fooWrapper = FooWrapper(foo: foo)
println(fooWrapper.fooName)
To make it work, either:
- Use
(foo as Foo).dynamicType.name
- Or, remove NSObject as the superclass of Foo