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 9148967
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T11:24:44+00:00 2026-06-17T11:24:44+00:00

I have a UITableView which I populate using a NSMutableArray . This tableview updates

  • 0

I have a UITableView which I populate using a NSMutableArray. This tableview updates when scrolled down, which is brought about by adding more data to the NSMutableArray. The problem I am facing is that everytime I navigate away from this page to another and then back again, the tableview is set to the initial size of the array, no matter how many updates I do (meaning if I load ten objects each time, the tableview size reverts back to 10 even if the array size is 30, note: the array size never changes only the table content size does). I am starting to believe this has to do with the properties of the NSMutableArray. The gist of the code is this:

@interface FlowViewController : UIViewController <UITableViewDataSource, UITableViewDelegate>
{
    UITableView *flowTable;

    NSMutableArray *cellData;

}
@property(nonatomic, retain) IBOutlet UITableView *flowTable;

@property(nonatomic, retain) NSMutableArray *cellData;

- (void) getData;
- (void) storeData: (NSMutableArray*) arr; 

@end

@implementation FlowViewController

@synthesize cellData;

@synthesize flowTable;

- (void)viewDidLoad
{
    [super viewDidLoad];

    self.flowTable.autoresizingMask = UIViewAutoresizingFlexibleHeight;

    [self.flowTable setDataSource:self];
    [self.flowTable setDelegate:self];

    self.cellData = [[NSMutableArray alloc] init];

    [self getData];
}

- (void) storeData:(NSMutableArray *)arr
{
    for(NSDictionary *data in arr)
    {

        CellObject *det = [[CellObject alloc] init];

        // store details

        [self.cellData addObject: det];

    }

    [self.flowTable reloadData];
}

- (void) getData
{

    NSString *url = @"http://example.com/";

    NSMutableURLRequest *theRequest= [NSMutableURLRequest requestWithURL:[NSURL URLWithString:url]
                                                             cachePolicy:NSURLRequestUseProtocolCachePolicy
                                                     timeoutInterval:10.0];

[theRequest setHTTPMethod:@"GET"];

flowConnection =[[NSURLConnection alloc] initWithRequest:theRequest delegate:self startImmediately:YES];

}


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

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 1;
}

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

    return [self.cellData count];
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    NSString *CellIdentifier = @"FlowCell";

    MyFlowCell *cell = (MyFlowCell *)[self.flowTable dequeueReusableCellWithIdentifier:CellIdentifier];

    if (cell == nil) {

        NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"FlowCell" owner:nil options:nil];
       // cell = [nib objectAtIndex:0];

        for(id currentObject in nib)
        {

        if([currentObject isKindOfClass:[MyFlowCell class]])

        {
            cell = (MyFlowCell *)currentObject;

        break;
    }
    }

    cell.selectionStyle = UITableViewCellSelectionStyleNone;

}

CellObject *rowItem = [cellData objectAtIndex:indexPath.row];

    // set cell data

}

    return cell;
}


- (void)tableView:(UITableView *)tableViewdidSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
[tableView deselectRowAtIndexPath:indexPath animated:YES];

    self.current = indexPath.row;

    [self performSegueWithIdentifier:@"flowToAnotherSegue" sender:nil];

}


- (void) prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{

    if ([segue.identifier isEqualToString:@"flowToAnotherSegue"])
    {
        NewViewController *iv =
            segue.destinationViewController;

    iv.current = self.current;
        iv.data = self.cellData;

    }

}


#pragma mark -
#pragma NSURLConnection Delegate Methods
- (void) connection:(NSURLConnection *)_connection didReceiveResponse:(NSURLResponse *)response {
    NSLog(@"Receiving response: %@, status %d", [(NSHTTPURLResponse*)response allHeaderFields],     [(NSHTTPURLResponse*) response statusCode]);
    receivedData = [NSMutableData data];
}

- (void) connection:(NSURLConnection *)_connection didFailWithError:(NSError *)error {
    NSLog(@"Connection Failed: %@", error);   
}

- (void) connection:(NSURLConnection *)_connection didReceiveData:(NSData *)_data {

       [receivedData appendData:_data];
}

- (void)connectionDidFinishLoading:(NSURLConnection *)connection
{

    // get the new NSMutableArray from receivedData

    [self storeData: newMutableArray];

}


#pragma mark -
#pragma mark Deferred image loading (UIScrollViewDelegate)

- (void)scrollViewDidScroll:(UIScrollView *)aScrollView {

    if(Bottom reached) {

       // load more data

        [self getData];

        }

    }
}

@end

I hope that is not too much. Please tell me where I might be going wrong.

  • 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-06-17T11:24:45+00:00Added an answer on June 17, 2026 at 11:24 am

    As I couldn’t find what is going wrong in my code, I have made a temporary fix. Like I said, the NSMutableArray cellData is not being changed, but the only thing that is changing is UITableView itself (I found this in my viewDidDisappear method). So I just did this to compensate for this

     - (void) viewDidAppear:(BOOL)animated
    {
        [self.flowTable reloadData];
    
        [self.flowTable scrollToRowAtIndexPath: lastIndex atScrollPosition:0 animated: NO];
    
    }
    

    This returns the flowTable to the last selected cell. It isn’t elegant, but it works. Please do keep posting your ideas. I really want to get to the bottom of this.

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

Sidebar

Related Questions

I have a UITableView which I want to populate with details from an array
I have a UITableView which displays about 5 cells at a time, yet in
this is driving me MAD now.. I have a UItableview. Based on an NSMutableArray,
I have a problem with using an NSArray to populate a UITableView. I'm sure
I have a UITableView which I am creating by using custom UITableViewCell . The
I have an array of objects which populate a UITableView . When a user
I have a UITableView which contains names in each row alongwith images for each
I have a UITableView which is configured to allow rows to be moved between
I have a UITableView which is backed by a NSFetchedResultsController . I would like
I have an UITableView which includes a list of UITableViewCells. And I set the

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.