lilzz
lilzz

Reputation: 5413

Special character output in NSString Iphone

NSString * url;
NSString * device;
NSString * API;
API      = @"http://www.test/";
device   = @"test123";
url      = [NSString stringWithFormat:@"%@update.json?dev=%20%20%20%@", API, device];

I want the final url to http://www.test/update.json?dev=%20%20%20%20test123; However the above I get only http://www.test/update.json?dev=22020test123; I want those %20 be part of literal string of url. How can I accomplish that?

Upvotes: 1

Views: 2617

Answers (2)

user1084563
user1084563

Reputation: 2169

To make a % sign since it's a special character you need to put %% for each % within an NSString.

Upvotes: 5

PawanShakya
PawanShakya

Reputation: 97

put \ before every special character. That should work.

Upvotes: 2

Related Questions