unsafeDowncast

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

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.