简体   繁体   中英

How to decode NSURL in iOS?

i am NewBie in iOS Development. I want to Decode my NSURL With Pagination Here my Url Like as

http://www.janvajevu.com/webservice/categorylist.php?category=%E0%AA%B8%E0%AB%8D%E0%AA%B5%E0%AA%BE%E0%AA%B8%E0%AB%8D%E0%AA%A5%E0%AA%AF&page=0

And i Decode this URL Like as

NSURL *urls = [NSURL URLWithString:@"http://www.janvajevu.com/webservice/categorylist.php?category=%E0%AA%B8%E0%AB%8D%E0%AA%B5%E0%AA%BE%E0%AA%B8%E0%AB%8D%E0%AA%A5%E0%AA%AF&page=0"];
NSString *urlString = [urls absoluteString];
NSLog(@"UrlString %@",urlString);
NSURL * url=[NSURL URLWithString:urlString];

But it Give me Only 0 Page Url i want to Like as make my url as

NSURL *urls=[NSURL URLWithString:@"My Url &page=%d",pagenum];

Here i want at place of My Url as Decoding of my Original Url If it is Possible then Please Give me Solution for it.

you are doing it in wrong way. this is the right way

NSString *urlString = @"http://www.janvajevu.com/webservice/categorylist.php?category=%E0%AA%B8%E0%AB%8D%E0%AA%B5%E0%AA%BE%E0%AA%B8%E0%AB%8D%E0%AA%A5%E0%AA%AF&page=";

NSURL *targetURL = [NSURL URLWithString:[NSString stringWithFormat:@"%@%d",urlString,pageNumber]];
NSLog(@"targetURL is : %@",targetURL);

Hope this will help you..

NSString *str=@" http://www.janvajevu.com/webservice/categorylist.php?category=%E0%AA%B8%E0%AB%8D%E0%AA%B5%E0%AA%BE%E0%AA%B8%E0%AB%8D%E0%AA%A5%E0%AA%AF&page=0 ";

NSString *result =[str stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];

NSURL *urls = [NSURL URLWithString:result] ;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM