Walid Hossain Walid Hossain - 1 year ago 78
iOS Question

iOS TableView loads data very slowly

I'm working on a project that parse data from web service and shows in a table view. Everything is ok, but I'm not satisfied with the performance of tableview. After parsing data form web I called reload data to show the data, But it is not showing cells immediately. It shows the data after 10/15 seconds later. I've checked all data's are loaded before I called reload data. And the strange thing is that it shows the cells immediately if I try to drag the table.

Any idea?


-(void)receivedCategories:(NSMutableArray *)categoryItems{
[self.spinner stopAnimating];
if (self.tableView!=nil) {
[self.tableView reloadData];

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

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
return [self.categories count];

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
static NSString *CellIdentifier = @"CategoryCell";
CategoryCell *cell = [self.tableView dequeueReusableCellWithIdentifier:CellIdentifier];
cell.category = [self.categories objectAtIndex:indexPath.row];
return cell;


@implementation CategoryCell

- (void)setCategory:(Category *)category
[self.categoryTitle setText:category.title ];
[self.categorySubTitle setText:category.description];


Answer Source

It seems you're not calling [self.tableView reloadData]; from the main thread and that could be the cause of your problem.

You could try:

[self.tableView performSelectorOnMainThread:@selector(reloadData) withObject:nil waitUntilDone:YES];

Also check the accepted answer here for more info.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download