unsafeDowncast

func unsafeDowncast<T where T : AnyObject>(_: AnyObject, to: T.Type)

returns: x as T.

Precondition: x is T. In particular, in -O builds, no test is performed to ensure that x actually has dynamic type T.

Warning: Trades safety for performance. Use unsafeDowncast only when x as! T has proven to be a performance problem and you are confident that, always, x is T. It is better than an unsafeBitCast because it's more restrictive, and because checking is still performed in debug builds.

Declaration

func unsafeDowncast<T where T : AnyObject>(_ x: AnyObject, to: T.Type) -> T