Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7674961
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T16:51:14+00:00 2026-05-31T16:51:14+00:00

Request my test webService for the data, The tableView’s last row is More data…

  • 0

Request my test webService for the data,

The tableView’s last row is “More data…”

when click this row, send another request to get more data,

and I use [tableView reloaddata] many times, but there is nothing

happened, and I dont know why.So,please help me with this problem.

Thank you in advance.

and there is my tableViewController.h class:

#import <UIKit/UIKit.h>

#import "NoticeDetailViewController.h"

@interface NoticeViewController : UIViewController
<UITableViewDataSource,UITableViewDelegate>
{    
    NSMutableArray *allNoticeArray;

    NSArray *addNoticeArray;

    NSInteger totalNotice;

    NSInteger pageIndex;

    UITableView *tableView;
}

@property (nonatomic, retain) NSMutableArray *allNoticeArray;
@property (nonatomic, retain) NSArray *addNoticeArray;
@property NSInteger totalNotice;
@property NSInteger pageIndex;
@property (nonatomic, retain) UITableView *tableView;
- (NSMutableArray *)getNoticeList :(NSInteger)pageIndex;
@end

And tableViewController.m class:

#import "NoticeViewController.h"
#import "Notice.h"
#import "OAURLEncodingAdditions.h"
@interface NoticeViewController ()
@end

@implementation NoticeViewController
@synthesize allNoticeArray;
@synthesize addNoticeArray;
@synthesize pageIndex;
@synthesize tableView;
@synthesize totalNotice;

- (NSMutableArray *)getNoticeList :(NSInteger)pageIndex
    { 
        AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
        NSString *userId = appDelegate.user.userId;
        NSString *departmentId = appDelegate.user.departmentId;

        NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"https://xxx.xxx.xx.xx/FMS/Pages/Service/FMService.svc/GetAnnouncement?userId=%@&departmentId=%@&pageIndex=%d&pageSize=%d",userId,departmentId,self.pageIndex,1]];
        ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:url];
        [request setValidatesSecureCertificate:NO];
        [request startSynchronous];
        NSError *error = [request error];
        if (!error) 
        {
            NSString *responseString = [request responseString];
            NSDictionary *responseDict = [responseString JSONValue];
            NSArray *noticeArray = [responseDict objectForKey:@"d"];

            NSMutableArray *arrayOfAllNotice = [[NSMutableArray alloc] init];

            for (NSDictionary *noticeDic in noticeArray) 
            {
                NSString *body = [noticeDic objectForKey:@"Body"];
                NSString *departmentName = [noticeDic objectForKey:@"DepartmentName"];
                NSString *noticeId = [noticeDic objectForKey:@"Id"];
                NSString *isTop = [noticeDic objectForKey:@"IsTop"];
                NSString *readState = [noticeDic objectForKey:@"ReadState"];
                NSString *realName = [noticeDic objectForKey:@"RealName"];
                NSString *title = [noticeDic objectForKey:@"Title"];

                int noid = [noticeId intValue];
                int isto = [isTop intValue];
                int read = [readState intValue];

                Notice *notice = [[Notice alloc] initWithBody:body 
                                       departmentName:departmentName 
                                             noticeId: noid 
                                                isTop:isto 
                                            readState:read 
                                             realName:realName 
                                                title:title];
                [arrayOfAllNotice addObject:notice];
            }
        self.addNoticeArray = [[NSArray alloc] initWithArray:arrayOfAllNotice];
    }
    else
    {
       ....
    }
    [allNoticeArray addObjectsFromArray:addNoticeArray];    
    NSLog(@"allNoticeArray count: %d",[allNoticeArray count]);  //Here:When the last row clicked, the number changes:1->2  
    [self.tableView reloadData]; 
    return allNoticeArray;
}

#pragma mark - 
#pragma mark Table View Data Source Methods

- (NSInteger) tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    NSInteger theNumberOfRowsInSection;

    if ( [allNoticeArray count] < (self.totalNotice)) 
    {
        theNumberOfRowsInSection = [allNoticeArray count]+1;
    }
    if ( [allNoticeArray count] == (self.totalNotice)) 
    {
        theNumberOfRowsInSection = [allNoticeArray count];
    }

    return theNumberOfRowsInSection; 
}

- (UITableViewCell *) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    [self.tableView reloadData];

    static NSString *NoticeListTableIdentifier = @"NoticeListTableIdentifier";
    UITableViewCell *cell = [self.tableView dequeueReusableCellWithIdentifier:NoticeListTableIdentifier];
    if ( cell == nil ) 
    {
        cell = [[[UITableViewCell alloc]
             initWithStyle:UITableViewCellStyleDefault reuseIdentifier:NoticeListTableIdentifier] autorelease];
    }

    if ( [allNoticeArray count] < (self.totalNotice) ) 
    {
        if ( [indexPath row] != [allNoticeArray count]) 
        {
            NSUInteger row = [indexPath row];
            Notice *noticeOfTheRow = [allNoticeArray objectAtIndex:row];
            NSString *title = noticeOfTheRow.title;
            cell.textLabel.text = title;
        }
        else 
        {
            cell.textLabel.text = @"More...";
        }
    }
    if ( [allNoticeArray count] == (self.totalNotice) ) 
    {
        NSUInteger row = [indexPath row];
        Notice *noticeOfTheRow = [allNoticeArray objectAtIndex:row];
        NSString *title = noticeOfTheRow.title;
        cell.textLabel.text = title;
    }

    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    if ( [indexPath row] != [allNoticeArray count]) 
    {        
        NSUInteger row = [indexPath row];       
        Notice *notice = [allNoticeArray objectAtIndex:row];        
        NSString *noticeDetailTitle = notice.title;        
        NoticeDetailViewController *noticeDetailViewController = [[[NoticeDetailViewController alloc] init] autorelease];
        noticeDetailViewController.title = noticeDetailTitle;        
        ticeDetailViewController.noticeIdForGet = notice.noticeId;        
        [self.navigationController pushViewController:noticeDetailViewController animated:YES];        
    }
    if ( [indexPath row] == [allNoticeArray count]) 
    {        
        MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
        hud.labelText = @"reload...";        
        self.pageIndex ++;        
        [self getNoticeList:self.pageIndex];        
        [self.tableView reloadData];        
        [MBProgressHUD hideHUDForView:self.view animated:YES];        
    }
}

- (void)pushBack
{
    [self dismissModalViewControllerAnimated:YES];
}

- (void)viewDidLoad
{
    [super viewDidLoad];  
    self.allNoticeArray = [[NSMutableArray alloc] init];
    self.pageIndex = 1;    
    MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
    hud.labelText = @"reload...";    
    self.title = @"Notice";    
    UIBarButtonItem *leftButton = [[UIBarButtonItem alloc] initWithTitle:@"back" 
                                                                       style:UIBarButtonItemStyleBordered 
                                                                      target:self 
                                                                      action:@selector(pushBack)];
self.navigationItem.leftBarButtonItem = leftButton;


    UIBarButtonItem *rightButton = [[UIBarButtonItem alloc] initWithTitle:@"reload" 
                                                                      style:UIBarButtonItemStyleBordered 
                                                                     target:self 
                                                                     action:@selector(reloadNotice)];
    self.navigationItem.rightBarButtonItem = rightButton;
    self.allNoticeArray = [self getNoticeList:self.pageIndex];    
    [MBProgressHUD hideHUDForView:self.view animated:YES];
 }
@end
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T16:51:15+00:00Added an answer on May 31, 2026 at 4:51 pm

    change:

    if ( [indexPath row] == [allNoticeArray count])
    

    to:

    if ( [indexPath row] == [allNoticeArray count]-1)
    

    The reason is that array (and row) indexing are base 0. So if an array has, say 3 objects, last object’s index is 2

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In my demo application, I try to send a request to my test WebService,
I tried to make http get request with code: String username = test\\v100; String
My flash code: var request=new URLRequest('http://localhost/test.php'); request.method = URLRequestMethod.POST; var data = new URLVariables();
Im trying to get a page talking to a webservice through jquery. this is
(sorry for the english) I have a ASP .net webservice that get data from
I'm getting 'Connection timed out' on a SOAP request to another company's webservice. I
I have this curl request below, which was successfully troubleshooted in another post. Right
We are designing a Stress Test Application which will send mass HTTP requests of
I am trying to test a rest webservice but when I do a post
I am trying to get jquery to communicate with a web service!! function Test(item)

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.