URL

struct URL : ReferenceConvertible, Equatable
  • SwifterSwift: Dictionary of the URL’s query parameters

    Declaration

    Swift

    public var queryParameters: [String : String]? { get }
  • SwifterSwift: URL with appending query parameters.

    let url = URL(string: "https://google.com")!
    let param = ["q": "Swifter Swift"]
    url.appendingQueryParameters(params) -> "https://google.com?q=Swifter%20Swift"
    

    Declaration

    Swift

    public func appendingQueryParameters(_ parameters: [String : String]) -> URL

    Parameters

    parameters

    parameters dictionary.

    Return Value

    URL with appending given query parameters.

  • SwifterSwift: Append query parameters to URL.

    var url = URL(string: "https://google.com")!
    let param = ["q": "Swifter Swift"]
    url.appendQueryParameters(params)
    print(url) // prints "https://google.com?q=Swifter%20Swift"
    

    Declaration

    Swift

    public mutating func appendQueryParameters(_ parameters: [String : String])

    Parameters

    parameters

    parameters dictionary.

  • SwifterSwift: Get value of a query key.

    var url = URL(string: https://google.com?code=12345)! queryValue(for: code) -> 12345

    Declaration

    Swift

    public func queryValue(for key: String) -> String?

    Parameters

    key

    The key of a query value.

  • SwifterSwift: Returns a new URL by removing all the path components.

    let url = URL(string: "https://domain.com/path/other")!
    print(url.deletingAllPathComponents()) // prints "https://domain.com/"
    

    Declaration

    Swift

    public func deletingAllPathComponents() -> URL

    Return Value

    URL with all path components removed.

  • SwifterSwift: Remove all the path components from the URL.

       var url = URL(string: "https://domain.com/path/other")!
       url.deleteAllPathComponents()
       print(url) // prints "https://domain.com/"
    

    Declaration

    Swift

    public mutating func deleteAllPathComponents()
  • Generate a thumbnail image from given url. Returns nil if no thumbnail could be created. This function may take some time to complete. It’s recommended to dispatch the call if the thumbnail is not generated from a local resource.

    var url = URL(string: "https://video.golem.de/files/1/1/20637/wrkw0718-sd.mp4")!
    var thumbnail = url.thumbnail()
    thumbnail = url.thumbnail(fromTime: 5)
    
    DisptachQueue.main.async {
        someImageView.image = url.thumbnail()
    }
    

    Declaration

    Swift

    public func thumbnail(fromTime time: Float64 = 0) -> UIImage?

    Parameters

    time

    Seconds into the video where the image should be generated.

    Return Value

    The UIImage result of the AVAssetImageGenerator