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

Returns the given instance cast unconditionally to the specified type.

The instance passed as x must be an instance of type T.

Use this function instead of unsafeBitcast(_:to:) because this function is more restrictive and still performs a check in debug builds. In -O builds, no test is performed to ensure that x actually has the dynamic type T.

Warning: This function trades safety for performance. Use unsafeDowncast(_:to:) only when you are confident that x is T always evaluates to true, and only after x as! T has proven to be a performance problem.

Parameters: x: An instance to cast to type T. type: The type T to which x is cast. Returns: The instance x, cast to type T.


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