0

Im having a big trouble with URl I want to use url for almofire , but unforutnately it always return nil or ortherwise , this solutuin return valid URL but with weird $$*%&$( in front of https:// an resulting to always got nil response

    let req = "​https://api-staging.xx.oo/v1/s-locations/"
    
    guard let percentReq = req.addingPercentEncoding(withAllowedCharacters: CharacterSet.urlQueryAllowed ) else { return nil }
    
    let urlReq = URL(string: percentReq)!

// work , url got , but fetch nothing

     let urlReq = URL(string: req)! 

// error FATAL

1 Answer 1

2

Honestly, looks like you managed to get some trash into the string by copy-pasting, I'm assuming it's encoding or something. This code from below works just fine:

let test = "https://api-staging.xx.oo/v1/s-locations/"
let url = URL(string: test)
Sign up to request clarification or add additional context in comments.

1 Comment

Indeed, and VSCode doesn't seem to be able to render it. (even with Control and Whitespace characters enabled) That's weird.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.