PhoneNumber
public struct PhoneNumber : IdentifierProtocol
Represents a phone number string
-
The string that is provided during initialization
Declaration
Swift
public var originalString: String { get }
-
The normalized form used internally (may or may not be different)
Declaration
Swift
public var normalizedString: String { get }
-
Represents the components of a full phone number, i.e. dialing code and number
Declaration
Swift
public struct Components
-
Create a PhoneNumber.Components object out of this PhoneNumber.
This will only work if you have used the initializer that allows seperation of code and parts
Declaration
Swift
public func components() throws -> Components
-
Initialize PhoneNumber identifier
The input strings are only allowed to have digits or spaces, with the exception of ‘+’ that may be present in the country code. There must be at least one digit in each string. The country code is normalized by removing ‘00’ in the front (if present) and adding ‘+’ as the first char.
Declaration
Swift
public init?(countryCode: String, number: String)
Parameters
countryCode
a phone number’s country code as a string to parse
identifier
a phone number as a string to parse
Return Value
PhoneNumber or nil if parsing fails
-
Initialize PhoneNumber identifier
Assumes the values passed in is a full phone number including the internal dialing code. The number is normalized by removing ‘00’ in the front (if present) and adding ‘+’ as the first char.
Declaration
Swift
public init?(fullNumber: String?)
Parameters
fullNumber
a phone number including full country code
Return Value
PhoneNumber or nil if parsing fails
-
Declaration
Swift
public static func == (lhs: PhoneNumber, rhs: PhoneNumber) -> Bool