Objective C - NSURL - Quotation mark

406 Views Asked by At

I have searched the website for answer without result so here I am with a question.

I am using CouchDB and i'm going to use a view but the problem is that I can't use quotation mark (") in an NSURL when I'm creating a url for NSURLConnection.

Here's my code:

NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"http://127.0.0.1:5984/users/_design/search/_view/phone?key=\"0701010100\""]];

CouchDB thinks it's a number if I don't use these quotation marks.

Thanks to all for your help.

Marcus

1

There are 1 best solutions below

1
On

use -stringByAddingPercentEscapesUsingEncoding:

NSURL *url = [NSURL URLWithString:[[NSString stringWithFormat:@"http://127.0.0.1:5984/users/_design/search/_view/phone?key=\"0701010100\""] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];