URLPredicate

public struct URLPredicate : Predicate

The URLPredicate struct is used to evaluate whether a given input is a syntactically valid URL.

let predicate = URLPredicate()
let isValid = predicate.evaluate(with: "http://www.swift.org")
  • Declaration

    Swift

    public typealias InputType = String
  • Returns a new URLPredicate instance.

    let predicate = URLPredicate()
    let isValid = predicate.evaluate(with: "http://www.swift.org")
    

    Declaration

    Swift

    public init()
  • Returns a Boolean value that indicates whether a given input is a valid URL.

    Declaration

    Swift

    public func evaluate(with input: InputType) -> Bool

    Parameters

    input

    The input against which to evaluate the receiver.

    Return Value

    true if input is a valid URL, otherwise false.