1
-(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++;

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

can perform like as .

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

1 Answer 1

1

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];
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.