简体   繁体   English

如何在json Web服务中传递参数和参数?

[英]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 . 在链接的最后,我们看到page = 1,我有10多个页面。 so how can i pass a variable/parameter/argument , so i can increment page no. 所以我该如何传递变量/参数/参数,这样我就可以增加页码。 Thanks in advance ' int page; page++; 在此先感谢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 . 在链接的最后,我们看到page = 1,我有10多个页面。 so how can i pass a variable/parameter/argument , so i can increment page no. 所以我该如何传递变量/参数/参数,这样我就可以增加页码。 Thanks in advance ' int page; page++; 在此先感谢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 . 您只需要接受一个int类型的变量(例如pageNo ),然后为其提供默认值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 . 您只需要增加pageNo (使用pageNo++ )来获取下一个页面值,然后您必须使用pageNo为URL创建字符串,然后使用NSURL类的URLWithString方法将其传递给URL。


Translation of all the above description in 4 easy steps using Objective-C : 使用Objective-C只需4个简单步骤即可将所有上述描述翻译为:

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];

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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