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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T09:58:20+00:00 2026-05-31T09:58:20+00:00

I have a UITableViewController which uses a NSMutableArray for it’s datasource. The array is

  • 0

I have a UITableViewController which uses a NSMutableArray for it’s datasource. The array is initially populated in the viewDidLoad method by calling a web service to retrieve the data and populate the NSMutableArray. The user then has the option to enter a search term (in a UISearchBar) and press Search to rerun the web service and repopulate the table list. At this point I need to empty the array and repopulate the table from the results of the web service. My question is what is the correct way to do this without upsetting the repainting of the table view? I can see 2 options :

  1. Call [listArray removeAllObjects]; then [[self tableView] reloadData]; before repopulating the array.

  2. As I restrict the list to a maximum of 200 rows, initialise the array with 200 items and then instead of removing and re-adding when the search is run, use [listArray replaceObjectAtIndex: to replace each row. This would then require an int variable to keep the number of rows returned and use this in the ‘tableView numberOfRowsInSection’ method so the tableview only displays the number of rows returned.

Hope that makes sense! I’m asking the question because I’ve had some intermittent errors (EXC_BAD_ACCESS) when re-loading the list and I’m convinced it’s to do with how I’m emptying and reloading the list so could use some advice on the best approach.

Any help appreciated,

Jonathan

UPDATE :

Code to initialise array in viewDidLoad :

tableListDataArray = [[NSMutableArray alloc] init];

Once data is retrieved, it is added to the array as follows :

CustSuppListItem *custSuppItem = [[CustSuppListItem alloc] init];
[custSuppItem setAcCode:[jsonCustSuppRecord getStringForKey:@"acCode"]];
[custSuppItem setAcCompany:[jsonCustSuppRecord getStringForKey:@"acCompany"]];
[custSuppItem setAcContact:[jsonCustSuppRecord getStringForKey:@"acContact"]];
[custSuppItem setOsBalBase:[jsonCustSuppRecord getDoubleForKey:@"osBalBase"]];
[custSuppItem setAcAccStatus:[jsonCustSuppRecord getIntForKey:@"acAccStatus"]];                             
[tableListDataArray addObject:custSuppItem];                          
[custSuppItem release];

The array is released in the dealloc method as follows :

[tableListDataArray release];
  • 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-31T09:58:21+00:00Added an answer on May 31, 2026 at 9:58 am

    I personally would go with option 1. You should just be able to use

    [tableView reloadData]
    

    without the “self”. reloadData will also call the cellForRowAtIndexPath method I believe
    Don’t forget to initialize your NSMutableArray before using it.

    myMutableArray  = [[NSMutableArray alloc] initWithCapacity:9001];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a UITableViewController which I'm populating with data from a web service. While
I have a UITableViewController which in it's tableView:didSelectRowAtIndexPath method, sets up a view controller,
I have an UITableViewController which I would like to add UIToolbar to with one
I am using a UITableViewController which uploads a table. I have a Nib File
I have a UITableViewController. In viewDidLoad I set the rowHeight: self.tableView.rowHeight = 43; But
I have a UITableViewController which creates dynamically re-sizeable cells. The cell changes the size
I have a UITableViewController which lets the user drill down into different records. On
I am using iPhone SDK 3.1.3. I have a UITableViewController which gets data from
I have a custom subclass of a UITableViewController which has a editable cells in
I have a UITableViewController which pushes a UIViewController and I need to pass two

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.