Questions tagged [nsurlcomponents]

NSURLComponents (or URLComponents in Swift) is a type that parses URLs into and constructs URLs from their constituent parts.

For more information, see the official documentation of NSURLComponents.

28 questions
0
votes
1 answer

Query keys are encoded in URLComponent's url

I'm using URLQueryItem to encode query values but when I pass queries to the URLComponent in the url property query keys are encoded too. var urlComponents = URLComponents(url: url, resolvingAgainstBaseURL: false) urlComponents.queryItems =…
Maysam
  • 7,246
  • 13
  • 68
  • 106
0
votes
1 answer

URL Encoding in swift converting space to %20 and then %20 to %2520

Here is the code struct URLParameterEncoder: ParameterEncoderProtocol { /// Takes dictionary parameters and encode them to make them safe to be passed as URLQueryItem in the URLRequest func encode(urlRequest: inout URLRequest, with…
Himan Dhawan
  • 894
  • 5
  • 23
0
votes
1 answer

How can I remove the "&" that keep appearing when the URL is printed?

How can I remove the "&" that keep appearing when the URL is printed? Why is it even appearing? var url = URLComponents() url.scheme = "http" url.host = "api.openweathermap.org" url.queryItems = [ URLQueryItem(name: "/data",…
user10459086
0
votes
3 answers

Swift 4 How to remove %EF%BB%BF from URL created from URLComponent()?

I attempt to create URL from components var com = URLComponents() com.scheme = "http" com.host = "192.168.1.99" com.port = 77 com.path = "/api/dosomething/55" print("SHOW ME URl = \(com.url!))") What I got is something like…
Nekkoko Nabby
  • 57
  • 2
  • 6
0
votes
2 answers

How can I use a # symbol instead of ? in URLQueryItem?

If I create a URL like this: guard var urlComponents = URLComponents(url: "https://example.com/something", resolvingAgainstBaseURL: false) else { return } let queryItems = URLQueryItem(name: "token", value: token) …
Ghislain Leblanc
  • 194
  • 2
  • 11
0
votes
3 answers

how to convert host of nsurl to lowercase

Let's say I have www.GOOgle.com/....... I want to change it to www.google.com/.... and keep the rest of url as it is. I have tried with NSURLComponents, but it didn't work. // I am taking input from textfield and making the nsurl. …
backbencher
  • 99
  • 2
  • 8
0
votes
1 answer

Swift3 URL from URLComponents, how to add OR query items

Im constructing a URL from query items using URLComponents and I want to add some query items as OR conditions rather than AND. Im not sure what the proper terminology for this is. Anyway I would like the following,…
R.P. Carson
  • 439
  • 5
  • 20
0
votes
1 answer

How to get params value from POST request in swift

First I fire post request When user submit that form debugger area in inspect element shows the value of params. But How I will get that value in native ios Swift ? Can any one have idea ? Some what I know NSURLComponents used but I am confused how…
Malay
  • 1
  • 2
0
votes
2 answers

Share Text, Image and Url on Google+ without login

I would like to share Image with Url on Google+ without login on my iOS app. I have used : NSString *temp = @"Hello World"; // Construct the Google+ share URL NSURLComponents* urlComponents = [[NSURLComponents alloc] …
-1
votes
1 answer

URLComponents fails on 'path' part

What if path is more complex? How can I get URLComponenets get work is path is this? urlComponents.path = "v3/sandbox115e22c785254f36953c9f28337689bb.mailgun.org/message" unfortunatelly it fails here: guard let uriString =…
János
  • 32,867
  • 38
  • 193
  • 353
-1
votes
1 answer

Remove ? from query string swift 4

I have a url in which I add URL components to it to form a query string. For example the url is https://example.com/test, and with the url components the final url is https://example.com/test?urlcomponent1=1&urlcomponent2=1234. I need to keep the…
jfulton
  • 77
  • 1
  • 10
-1
votes
1 answer

Avoid percent encoding of host in URLComponents

Using URLComponents, is there a way to avoid percent encoding of host? var components = URLComponents() components.scheme = "https" components.host = "endpoint.com/v1/api.php?" // ends up as https://endpoint.com%2Fv1%2Fapi.php%3F? but I want it to…
nambatee
  • 1,478
  • 16
  • 27
-2
votes
1 answer

Swift. Convert percent encoding symbols in string, to their ascii representation

I'm using the Swift framework ASWebAuthenticationSession in order to add authentication via browser for my application. After processing the credentials, the authentication provider send URL with special prefix which gets intercepted by my app. The…
Zohar81
  • 4,554
  • 5
  • 29
  • 82
1
2