Alex
Alex

Reputation: 81

(iPhone)URL formatting question

I am trying to format a URL but am getting a bug out of it. My code is below.

NSString *twitterURL = [NSString stringWithFormat:@"http://twitter.com/?status=My%20score%20is:%i%20and%20CharsPerMin%20is:%@", currentScore, charPerMin.text]; 

When calling the method it doesn't do a thing. I think the issue is with %20. %20 is being used to space each word in the URL.

Upvotes: 0

Views: 181

Answers (1)

Senseful
Senseful

Reputation: 91711

You need to escape your % signs by doubling them:

NSString *twitterURL = [NSString stringWithFormat:@"http://twitter.com/?status=My%%20PracticeTyper%%20score%%20is:%i%%20and%%20CharsPerMin%%20is:%@", currentScore, charPerMin.text];

Upvotes: 3

Related Questions