%20
is nothing but white space.
Because of stringByAddingPercentEscapesUsingEncoding:NSASCIIStringEncoding
you see space as %20
.
If you have whitespace at the end, use below code to remove it.
NSString *string = @" this text has spaces before and after ";
NSString *trimmedString = [string stringByTrimmingCharactersInSet:
[NSCharacterSet whitespaceCharacterSet]];