protocol
Streamable
Inheritance | View Protocol Hierarchy → |
---|---|
Import |
|
Instance Methods
Writes a textual representation of this instance into the given output stream.
Declaration
func
write
<
Target
:
OutputStream
>
(
to
target
:
inout
Target
)
A source of text-streaming operations.
Instances of types that conform to the
Streamable
protocol can write their value to instances of any type that conforms to theOutputStream
protocol. The Swift standard library's text-related types,String
,Character
, andUnicodeScalar
, all conform toStreamable
.Conforming to the Streamable Protocol
To add
Streamable
conformance to a custom type, implement the requiredwrite(to:)
method. Call the given output stream'swrite(_:)
method in your implementation.