简体   繁体   中英

how to pass arguments and parameters in json web service?

-(void)gettop10button
{   
    NSURL *url=[NSURL URLWithString:@"http://appabn.com/iphone/files/api/api.php?q=helo_users&u_id=5&page=1"];  // web api link

    NSURLRequest *request=[NSURLRequest requestWithURL:url];
    connection=[NSURLConnection connectionWithRequest:request delegate:self];

in the last of the link we see that page=1 , i have more than 10 pages . so how can i pass a variable/parameter/argument , so i can increment page no. Thanks in advance ' int page; page++; int page; page++;

can perform like as .

in the last of the link we see that page=1 , i have more than 10 pages . so how can i pass a variable/parameter/argument , so i can increment page no. Thanks in advance ' int page; page++; int page; page++;

can perform like as .

if(connection)
{
    webData=[[NSMutableData alloc]init];
}   
[JustConfesstable reloadData];

It's so simple. I am still amazed which part of the code you are not getting. You just have to take one variable (say pageNo ) of type int and then provide it the default value 1 . You just have to increment the pageNo (using pageNo++ ) to get the next page value and then you have to create string for URL with pageNo and then simply pass it to URL using the method called URLWithString of class NSURL .


Translation of all the above description in 4 easy steps using Objective-C :

NSString *urlString = [NSString stringWithFormat:@"http://appabn.com/iphone/files/api/api.php?q=helo_users&u_id=5&page=%d",pageNo];
NSURL *url = [NSURL URLWithString:urlString];  // web api link
NSURLRequest *request = [NSURLRequest requestWithURL:url];
connection = [NSURLConnection connectionWithRequest:request delegate:self];

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