Advertisement
Guest User

Untitled

a guest
Jan 26th, 2015
193
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. - (NSURL *)hitListURLWithTaskTitle:(NSString *)title {
  2. // Basic URL as a starting point
  3. NSURLComponents *components = [NSURLComponents componentsWithString:@"thehitlist:///inbox/tasks"];
  4.  
  5. components.queryItems = @[
  6. [NSURLQueryItem queryItemWithName:@"method" value:@"POST"],
  7. [NSURLQueryItem queryItemWithName:@"title" value:title]
  8. ];
  9.  
  10. // NSURLQueryItem has encoded any spaces as %20 which is fine
  11. // But + symbols are untouched, which will be mis-interpreted
  12. // So post-process to encode them ourselves
  13. components.percentEncodedQuery = [components.percentEncodedQuery
  14. stringByReplacingOccurrencesOfString:@"+"
  15. withString:@"%2B"];
  16.  
  17. return components.URL;
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement