Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Creating a Hit List URL with + symbols in query items properly encoded
- (NSURL *)hitListURLWithTaskTitle:(NSString *)title {
// Basic URL as a starting point
NSURLComponents *components = [NSURLComponents componentsWithString:@"thehitlist:///inbox/tasks"];
components.queryItems = @[
[NSURLQueryItem queryItemWithName:@"method" value:@"POST"],
[NSURLQueryItem queryItemWithName:@"title" value:title]
// NSURLQueryItem has encoded any spaces as %20 which is fine
// But + symbols are untouched, which will be mis-interpreted
// So post-process to encode them ourselves
components.percentEncodedQuery = [components.percentEncodedQuery
return components.URL;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.