Swift Dictionary Extension to Create a URL Query String

Posted 09/27/2016 1:02 PM by Corey Klass

One of the more common parts of web-based client/server app architecture is converting groups of strings into URL-encoded values that can be included in a URL or form data. It's a tedious process, and I've found the easiest approach to take is put all of my URL or form variables into a dictionary and then call a function on that dictionary to convert it to a URL query string. I've encapsulated this logic into an extension for the Dictionary type.

It requires my String URL-Encoding Extension that I've previously posted.

You can find the source for my extension on Github