Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

496
Views
¿Cómo codificar la cadena de URL correctamente para evitar que el signo de interrogación (?) sea% 3F en Swift?

Estoy enviando una solicitud al servidor usando el pod de Alamofire .

 var urlComponents = URLComponents(string: "/hotel/v2")! urlComponents.queryItems = [ URLQueryItem(name: "page", value: page) ] let urlString = urlComponents.url?.absoluteString var urlRequest = URLRequest(url: url.appendingPathComponent(urlString))

El problema comienza cuando imprimo la urlRequest . Se muestra como: ingrese la descripción de la imagen aquí

Luego, la solicitud llega al backend y el backend me devuelve algún error.

over 4 years ago · Santiago Trujillo
2 answers
Answer question

0

No use url.appendingPathComponent . Ha creado un URLComponents . Úselo correctamente.

 var urlComponents = URLComponents(string: url)! urlComponents.path = "/hotel/v2" urlComponents.queryItems = [ URLQueryItem(name: "page", value: page) ] var urlRequest = URLRequest(url: urlComponents.url!)

Aquí asumo que la url es algo así como "https://somedomain.com" .

over 4 years ago · Santiago Trujillo Report

0

Simplemente puede hacer esto: Swift 4 y 5

 let url = URL(string: APIServant.API_DEV_URL + path)! var urlRequest = URLRequest(url: url)
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!