0

I am referring the answer here: https://stackoverflow.com/a/24061386/58129

The code is reproduced here:

var clazz: NSObject.Type = TestObject.self
var instance : NSObject = clazz()

if let testObject = instance as? TestObject {
    println("yes!")
}

If I tried it in a playground in XCode6 beta6, it throws an exception:

enter image description here

Is it no long valid to instantiate a class by calling T.self()

Community
  • 1
  • 1
Anthony Kong
  • 37,791
  • 46
  • 172
  • 304
  • https://developer.apple.com/library/prerelease/mac/documentation/Swift/Conceptual/Swift_Programming_Language/Types.html – Bryan Chen Aug 22 '14 at 03:12
  • Seems like an issue with playgrounds. I got the same error in a playground, but works when thrown into a non-playground project – jou Aug 22 '14 at 09:40

0 Answers0