Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Writing your own api client #13

Open
rajohns08 opened this issue Mar 27, 2016 · 2 comments
Open

Writing your own api client #13

rajohns08 opened this issue Mar 27, 2016 · 2 comments
Assignees

Comments

@rajohns08
Copy link

https://github.com/nickoneill/thatthinginswift/blob/master/content/write-your-own-api-clients-swift.md

I had to make paramString += "\(escapedKey)=\(escapedValue)&"

to unwrap like paramString += "\(escapedKey!)=\(escapedValue!)&"

to get this to work

@nickoneill
Copy link
Owner

Thanks @rajohns08, looks like stringByAddingPercentEncodingWithAllowedCharacters calls generate optionals there. I'll wrap them in an if let block.

@jdanthinne
Copy link

Additionally, I had to change the value variable to a String before adding the encoding:

let escapedValue = String(value).stringByAddingPercentEncodingWithAllowedCharacters(.URLQueryAllowedCharacterSet())

instead of

let escapedValue = value.stringByAddingPercentEncodingWithAllowedCharacters(.URLQueryAllowedCharacterSet())

otherwise I get a NSException.

@nickoneill nickoneill self-assigned this Feb 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants