A blog for technology, SEO tips, website development and open source programming.

Make Query URL using swift 3

0 980

Some times we need to extract some data or get the specific key data from URL. In order to achieve that we need to break the whole url string in “&” and we have to store data as  array in a variable. After that we have to make search so doing this , is taking more time and more complexity. The post will show a simple and easy way to Make Query URL using swift 3.

So let’s get started,

here is an example url: http://www.example.com?foo=bar&foo2=bar2

the url params are foo and foo2

We are going to use URLComponents method as it provides us the better way to handle the  query on URL.

Here queryItems contains all params data therefore we are doing the query on this params and filtering by name so foo will provide the respected value “bar”

[alert type=white ]

Don’t miss out

Error Handling in Swift

How to use Font Awesome in Swift

[/alert]

Leave a Reply

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More