I am a beginner in iOS development, recently I am learning about networking with rest API in iOS development. When constructing URL to make request, I found code like this:
var queryComponents: [URLQueryItem] {
var components = [URLQueryItem]()
for (key, value) in parameters {
let queryItem = URLQueryItem(name: key, value: "\(value)")
components.append(queryItem)
}
return components
}
I don't understand why the array component shall be in URLQueryItem data type.
Thanks in advance :)