typealias
AnyClass
=
AnyObject
.
Type
typealias
ArrayLiteralConvertible
=
ExpressibleByArrayLiteral
typealias
BooleanLiteralConvertible
=
ExpressibleByBooleanLiteral
typealias
BooleanLiteralType
=
Bool
The default type for an otherwise-unconstrained Boolean literal.
When you create a constant or variable using one of the Boolean literals
true
or false
, the resulting type is determined by the
BooleanLiteralType
alias. For example:
let
isBool
=
true
(
"isBool is a '\(
type
(
of
:
isBool
)
)'"
)
// Prints "isBool is a 'Bool'"
The type aliased by BooleanLiteralType
must conform to the
ExpressibleByBooleanLiteral
protocol.
The C 'char' type.
This will be the same as either CSignedChar
(in the common
case) or CUnsignedChar
, depending on the platform.
typealias
CChar32
=
UnicodeScalar
The C++11 'char32_t' type, which has UTF-32 encoding.
typealias
CSignedChar
=
Int8
The C 'signed char' type.
typealias
CUnsignedChar
=
UInt8
The C 'unsigned char' type.
typealias
CUnsignedInt
=
UInt32
The C 'unsigned int' type.
typealias
CUnsignedLong
=
UInt
The C 'unsigned long' type.
typealias
CUnsignedLongLong
=
UInt64
The C 'unsigned long long' type.
typealias
CUnsignedShort
=
UInt16
The C 'unsigned short' type.
typealias
CWideChar
=
UnicodeScalar
The C++ 'wchar_t' type.
typealias
ExtendedGraphemeClusterType
=
String
The default type for an otherwise-unconstrained Unicode extended grapheme cluster literal.
typealias
FloatLiteralConvertible
=
ExpressibleByFloatLiteral
typealias
FloatLiteralType
=
Double
The default type for an otherwise-unconstrained floating point literal.
typealias
IntegerLiteralConvertible
=
ExpressibleByIntegerLiteral
typealias
IntegerLiteralType
=
Int
The default type for an otherwise-unconstrained integer literal.
typealias
NilLiteralConvertible
=
ExpressibleByNilLiteral
Deprecated: it will be replaced or redesigned in Swift 4.0. Instead of conforming to 'StringInterpolationConvertible', consider adding an 'init(_:String)'.
typealias
StringLiteralConvertible
=
ExpressibleByStringLiteral
typealias
StringLiteralType
=
String
The default type for an otherwise-unconstrained string literal.
typealias
UnfoldFirstSequence
<
T
>
=
UnfoldSequence
<
T
, (
T
?,
Bool
)
>
The return type of sequence(first:next:)
.
typealias
UnicodeScalarType
=
String
The default type for an otherwise-unconstrained unicode scalar literal.
typealias
Void
= ()
The return type of functions that don't explicitly specify a return type;
an empty tuple (i.e., ()
).
When declaring a function or method, you don't need to specify a return
type if no value will be returned. However, the type of a function,
method, or closure always includes a return type, which is Void
if
otherwise unspecified.
Use Void
or an empty tuple as the return type when declaring a
closure, function, or method that doesn't return a value.
The protocol to which all class types implicitly conform.
You can use the
AnyClass
protocol as the concrete type for an instance of any class. When you do, all known@objc
class methods and properties are available as implicitly unwrapped optional methods and properties, respectively. For example:The
getDefaultValue(_:)
function uses optional chaining to safely call the implicitly unwrapped class method onc
. Calling the function with different class types shows how thegetDefaultValue()
class method is only conditionally available.See Also:
AnyObject