Bharathi D Bharathi D - 4 months ago 14
iOS Question

How to remove %20 in alertview ios

in ios alertview i have %20 symbol how to remove this..

enter image description here

this is my code

NSString *titile = result;
NSString *notifiText=txtresult;

alertView = [[UIAlertView alloc]initWithTitle:title message:notifiText delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"Ok", nil, nil];
[alertView show]

i just want output like this instead of %20 i want space..


Since you're likely retrieving your alert text from the web or from a JSON/XML response, the string is coming in encoded with "percent escapes". You need to remove them before displaying your alert.

And lucky for you, NSString has a handy method named stringByReplacingPercentEscapesUsingEncoding (I've linked Apple's documentation).