0

I want to configure URL with components. Please take a look:

var urlComponents = URLComponents(string: "https://itunes.apple.com/search?media=music&entity=song")
var queryItem = URLQueryItem(name: "term", value: "crowded house")
let urlForce = urlComponents?.url!

When i try to look in playgrounds witch properties have been set, following properties as ok:

urlForce?.absoluteString
urlForce?.scheme
urlForce?.host
urlForce?.path
urlForce?.query

But urlForce?.baseURL is nil. How to form url with all properties is set? I only know that following:

URL(string: "search", relativeTo: baseURL)

Set base url, but in that case i dont know how to add url components.

I want to form url with all properties are defined.

Evgeniy Kleban
  • 6,794
  • 13
  • 54
  • 107

0 Answers0