parseStrategy
TypeScriptget parseStrategy(): URL_ParseStrategySwift declarationvar parseStrategy: URL.ParseStrategy { get }The parse strategy used by this format style.
struct · iOS 16.0+ · SDK 27.1
struct FormatStyleA structure that converts between URL instances and their textual representations.
get parseStrategy(): URL_ParseStrategySwift declarationvar parseStrategy: URL.ParseStrategy { get }The parse strategy used by this format style.
host(strategy?: URL_FormatStyle_HostDisplayOption): URL_FormatStyleSwift declarationfunc host(_ strategy: URL.FormatStyle.HostDisplayOption = .always) -> URL.FormatStyleModifies a format style to display a URL's host component in accordance with the provided option. - Parameter strategy: A host display option that indicates when, if ever, to display the host component. - Returns: A modified ``URL/FormatStyle`` that incorporates the specified behavior.
path(strategy?: URL_FormatStyle_ComponentDisplayOption): URL_FormatStyleSwift declarationfunc path(_ strategy: URL.FormatStyle.ComponentDisplayOption = .always) -> URL.FormatStyleModifies a format style to display a URL's path component in accordance with the provided option. - Parameter strategy: A component display option that indicates when, if ever, to display the path component. - Returns: A modified ``URL/FormatStyle`` that incorporates the specified behavior.
port(strategy?: URL_FormatStyle_ComponentDisplayOption): URL_FormatStyleSwift declarationfunc port(_ strategy: URL.FormatStyle.ComponentDisplayOption = .omitIfHTTPFamily) -> URL.FormatStyleModifies a format style to display a URL's port component in accordance with the provided option. - Parameter strategy: A component display option that indicates when, if ever, to display the port component. - Returns: A modified ``URL/FormatStyle`` that incorporates the specified behavior.
user(strategy?: URL_FormatStyle_ComponentDisplayOption): URL_FormatStyleSwift declarationfunc user(_ strategy: URL.FormatStyle.ComponentDisplayOption = .never) -> URL.FormatStyleModifies a format style to display a URL's user component in accordance with the provided option. - Parameter strategy: A component display option that indicates when, if ever, to display the user component. - Returns: A modified ``URL/FormatStyle`` that incorporates the specified behavior.
query(strategy?: URL_FormatStyle_ComponentDisplayOption): URL_FormatStyleSwift declarationfunc query(_ strategy: URL.FormatStyle.ComponentDisplayOption = .never) -> URL.FormatStyleModifies a format style to display a URL's query component in accordance with the provided option. - Parameter strategy: A component display option that indicates when, if ever, to display the query component. - Returns: A modified ``URL/FormatStyle`` that incorporates the specified behavior.
format(value: string): stringSwift declarationfunc format(_ value: URL) -> StringFormats a URL, using this style. Use this method when you want to create a single style instance, and then use it to format multiple URL instances. The following example creates a custom format style and then uses it to format a variety of URLs in an array: ```swift let style = URL.FormatStyle( scheme: .never, user: .never, password: .never, host: .omitSpecificSubdomains(["www", "mobile", "m."], includeMultiLevelSubdomains: true), port: .never, path: .always, query: .never, fragment: .never) let urls = [ URL(string: "https://www.example.com/path/one")!, URL(string: "https://beta.example.com/path/two")!, URL(string: "https://beta.staging.west.example.com/three")!, URL(string: "https://query.example.com/four?key4=value4")! ] let formatted = urls.map { $0.formatted(style) } // ["example.com/path/one", "beta.example.com/path/two", "west.example.com/three", "query.example.com/four"] ``` To format a single URL value, use the ``URL`` instance method ``URL/formatted(_:)`` passing in an instance of ``URL/FormatStyle``, or ``URL/formatted()`` to use a default style. - Parameter value: The URL to format. - Returns: A string representation of `value`, formatted according to the style's configuration.
static init(scheme?: URL_FormatStyle_ComponentDisplayOption, user?: URL_FormatStyle_ComponentDisplayOption, password?: URL_FormatStyle_ComponentDisplayOption, host?: URL_FormatStyle_HostDisplayOption, port?: URL_FormatStyle_ComponentDisplayOption, path?: URL_FormatStyle_ComponentDisplayOption, query?: URL_FormatStyle_ComponentDisplayOption, fragment?: URL_FormatStyle_ComponentDisplayOption): URL_FormatStyleSwift declarationinit(scheme: URL.FormatStyle.ComponentDisplayOption = .always, user: URL.FormatStyle.ComponentDisplayOption = .never, password: URL.FormatStyle.ComponentDisplayOption = .never, host: URL.FormatStyle.HostDisplayOption = .always, port: URL.FormatStyle.ComponentDisplayOption = .omitIfHTTPFamily, path: URL.FormatStyle.ComponentDisplayOption = .always, query: URL.FormatStyle.ComponentDisplayOption = .never, fragment: URL.FormatStyle.ComponentDisplayOption = .never)Creates a new `FormatStyle` with the given configurations. - Parameters: - scheme: The strategy to use for formatting the `scheme`. - user: The strategy to use for formatting the `user`. - password: The strategy to use for formatting the `password`. - host: The strategy to use for formatting the `host`. - port: The strategy to use for formatting the `port`. - path: The strategy to use for formatting the `path`. - query: The strategy to use for formatting the `query`. - fragment: The strategy to use for formatting the `fragment`.
scheme(strategy?: URL_FormatStyle_ComponentDisplayOption): URL_FormatStyleSwift declarationfunc scheme(_ strategy: URL.FormatStyle.ComponentDisplayOption = .always) -> URL.FormatStyleModifies a format style to display a URL's scheme component in accordance with the provided option. - Parameter strategy: A component display option that indicates when, if ever, to display the scheme. - Returns: A modified ``URL/FormatStyle`` that incorporates the specified behavior.
fragment(strategy?: URL_FormatStyle_ComponentDisplayOption): URL_FormatStyleSwift declarationfunc fragment(_ strategy: URL.FormatStyle.ComponentDisplayOption = .never) -> URL.FormatStyleModifies a format style to display a URL's fragment component in accordance with the provided option. - Parameter strategy: A component display option that indicates when, if ever, to display the fragment component. - Returns: A modified ``URL/FormatStyle`` that incorporates the specified behavior.
password(strategy?: URL_FormatStyle_ComponentDisplayOption): URL_FormatStyleSwift declarationfunc password(_ strategy: URL.FormatStyle.ComponentDisplayOption = .never) -> URL.FormatStyleModifies a format style to display a URL's password component in accordance with the provided option. - Parameter strategy: A component display option that indicates when, if ever, to display the password component. - Returns: A modified ``URL/FormatStyle`` that incorporates the specified behavior.
No declarations were skipped in this snapshot.