func unsafeDowncast <T>(AnyObject, to: T.Type) -> T
The instance to cast to type
.
type
にキャストすることになるインスタンス。
Availability
Technology
func unsafeBitCast<T, U>(_ x: T, to type: U.Type) -> U
x
The instance to cast to type
.
type
にキャストすることになるインスタンス。
type
The type to cast x
to. type
and the type of x
must have the same size of memory representation and compatible memory layout.
x
をこれにキャストすることになる型。type
とx
の型は、同じ大きさのメモリ表現を持ち、互換メモリレイアウトを持たなければなりません。
A new instance of type U
, cast from x
.
型U
の新しいインスタンス、x
からキャストされます。
Use this function only to convert the instance passed as x
to a layout-compatible type when conversion through other means is not possible. Common conversions supported by the Swift standard library include the following:
この関数をx
として渡されるインスタンスをレイアウト互換の型へと、その変換が他の手段では可能でない場合に、変換するのにだけ使ってください。Swift標準ライブラリによってサポートされる一般的な変換は、以下を含みます:
Warning 警告
Calling this function breaks the guarantees of the Swift type system; use with extreme care. この関数を呼ぶことは、Swift型システムの保証を壊します;最大限の注意を払ってください。
Value conversion from one integer type to another. Use the destination type’s initializer or the numeric
function.
ある整数型から別のものへの値変換。行き先の型のもつイニシャライザまたはnumeric
関数を使ってください。
Bitwise conversion from one integer type to another. Use the destination type’s init(truncating
or init(bit
initializer.
ある整数型から別のものへのビット単位変換。行き先の型のもつinit(truncating
またはinit(bit
イニシャライザを使ってください。
Conversion from a pointer to an integer value with the bit pattern of the pointer’s address in memory, or vice versa. Use the init(bit
initializer for the destination type.
あるポインタからそのポインタのもつメモリでのアドレスのビットパターンをもつ整数値への変換、またはその逆。行き先の型のためのinit(bit
イニシャライザを使ってください。
Casting an instance of a reference type. Use the casting operators (as
, as!
, or as?
) or the unsafe
function. Do not use unsafe
with class or pointer types; doing so may introduce undefined behavior.
参照型のインスタンスのキャスト。キャスト演算子(as
、as!
、またはas?
)またはunsafe
関数を使ってください。unsafe
をクラスまたはポインタ型で使わないでください;そうすることは未定義挙動を導きます。
func unsafeDowncast <T>(AnyObject, to: T.Type) -> T