I made a quick category to help resolve this :)
@interface NSString (stringByDecodingURLFormat)
- (NSString *)stringByDecodingURLFormat;
@end
@implementation NSString
- (NSString *)stringByDecodingURLFormat
{
NSString *result = [(NSString *)self stringByReplacingOccurrencesOfString:@"+" withString:@" "];
result = [result stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
return result;
}
@end
Once defined, this quickly can handle an encoded string:
NSString *decodedString = [myString stringByDecodingURLFormat];
Plenty of other ways to implement.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…