Creates an instance initialized to the specified integer value.
Do not call this initializer directly. Instead, initialize a variable or
constant using an integer literal. For example:
let x = 23
In this example, the assignment to the `x` constant calls this integer
literal initializer behind the scenes.
- Parameter value: The value to create.
A textual representation of this instance, suitable for debugging.
Calling this property directly is discouraged. Instead, convert an
instance of any type to a string by using the `String(reflecting:)`
initializer. This initializer works with any type, and uses the custom
`debugDescription` property for types that conform to
`CustomDebugStringConvertible`:
struct Point: CustomDebugStringConvertible {
let x: Int, y: Int
var debugDescription: String {
return "(\(x), \(y))"
}
}
let p = Point(x: 21, y: 30)
let s = String(reflecting: p)
print(s)
// Prints "(21, 30)"
The conversion of `p` to a string in the assignment to `s` uses the
`Point` type's `debugDescription` property.
Creates a new instance with the specified raw value.
If there is no value of the type that corresponds with the specified raw
value, this initializer returns `nil`. For example:
enum PaperSize: String {
case A4, A5, Letter, Legal
}
print(PaperSize(rawValue: "Legal"))
// Prints "Optional(PaperSize.Legal)"
print(PaperSize(rawValue: "Tabloid"))
// Prints "nil"
- Parameter rawValue: The raw value to use for the new instance.
get · iOS 12.0+
rawValue
TypeScript
getRawValue($self: NWEndpoint_Port): number
Swift declaration
var rawValue: UInt16 { get }
The corresponding value of the raw type.
A new instance initialized with `rawValue` will be equivalent to this
instance. For example:
enum PaperSize: String {
case A4, A5, Letter, Legal
}
let selectedSize = PaperSize.Letter
print(selectedSize.rawValue)
// Prints "Letter"
print(selectedSize == PaperSize(rawValue: selectedSize.rawValue)!)
// Prints "true"
init · iOS 12.0+
init
TypeScript
init(service: string): (NWEndpoint_Port) | null
Swift declaration
init?(_ service: String)
Create a port from a string.
Supports common service names such as "http" as well as number strings such as "80".
- Parameter service: A service string such as "http" or a number string such as "80"
- Returns: A port if the string can be converted to a port, nil otherwise.