I'm trying to Decode URL,but i'm getting warning message like "NSString may not respond to URLDecode".
NSString* token = [[urlStr substringFromIndex:r.location + 1] URLDecode];
Any ideas?
I'm trying to Decode URL,but i'm getting warning message like "NSString may not respond to URLDecode".
NSString* token = [[urlStr substringFromIndex:r.location + 1] URLDecode];
Any ideas?
Because it is not a method a classic NSString respond to, you can though add a category like the following, to add the method yourself :
@interface NSString (URLDecode)
- (NSString *)URLDecode;
@end
@implementation NSString
- (NSString *)URLDecode
{
NSString *result = [(NSString *)self stringByReplacingOccurrencesOfString:@"+" withString:@" "];
result = [result stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
return result;
}
@end
Try like this.
NSString* urlEncoded = [urlStr stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
and check this link https://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/Reference/NSString.html#//apple_ref/doc/uid/TP40003744
it may help you.