mBrissman
mBrissman

Reputation: 136

Objective C - NSURL - Quotation mark

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

Upvotes: 0

Views: 399

Answers (1)

Jeffery Thomas
Jeffery Thomas

Reputation: 42598

use -stringByAddingPercentEscapesUsingEncoding:

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

Upvotes: 1

Related Questions