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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T19:44:38+00:00 2026-05-24T19:44:38+00:00

I am working on an application in which data is displaying from back end

  • 0

I am working on an application in which data is displaying from back end to tableview.
The problem is, when table is loading, it gets all the data but displays only the last entry of database in each row. suppose last section has 3 rows then it displays only3 that 3 row data in each section.Even if in some section rows are 9 then the rest of rows are displaying blank.

I found it through break points that table first takes all the data from database and then read cellForRowAtIndexPath, As in my database last table has 3 rows, it displays the data of 3 rows only by keeping rest of rows blank.

Here is the coe of my numberOfRowsInSection and cellForRowAtIndexPath

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    // Return the number of rows in the section.

    if(requestType == 2) 
    {       
        if (self.uniqueCityCount > 0) 
        {
            NSString *strCity = [self.arrayCityNames objectAtIndex:section];            //@"EventData" :@"EventCity"
            NSPredicate *predicateSettings =  [NSPredicate predicateWithFormat:@"(EventCity = %@ )",strCity]; 
            if ([self.arrayEventDescription count]>0)
            {
                [self.arrayEventDescription removeAllObjects];
            }
            self.arrayEventDescription = [CoreDataAPIMethods searchObjectsInContext:@"EventData" :predicateSettings :@"EventCity" :YES :self.managedObjectContext];
            return [self.arrayEventDescription count];  
        }
        /*
         if (section == 0)
         {
         NSString *strCity = [self.arrayCityNames objectAtIndex:section];           //@"EventData" :@"EventCity"
         NSPredicate *predicateSettings =  [NSPredicate predicateWithFormat:@"(EventCity = %@ )",strCity]; 
         self.arrayEventDescription = [CoreDataAPIMethods searchObjectsInContext:@"EventData" :predicateSettings :@"EventCity" :YES :self.managedObjectContext];
         return [self.arrayEventDescription count]; 
         }
         else if (section == 1)
         {

         }*/
    }       
return 0;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{    
NSString *CellIdentifier = [@"" stringByAppendingFormat:@"Cell%d",indexPath.row];      
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];

cell.backgroundColor = [UIColor clearColor];

if(requestType == 2)
{   
    if (cell == nil)
    {
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];

        //  for (int j = 0 ; j < [self.arrayEventDescription count]; j++)

        //  for(int j=0; j<[tableView numberOfSections]; j++)

        //{

        NSLog(@"at section %d",indexPath.section);
        NSLog(@"at row %d",indexPath.row);
        NSLog(@"array count %d",[self.arrayEventDescription count]);

        if (indexPath.row < [self.arrayEventDescription count]) 
        {


            EventData *data = [self.arrayEventDescription objectAtIndex:indexPath.row];
            //EventData *data = [self.arrayEventDescription objectAtIndex:j];

            cell.selectionStyle=UITableViewCellSelectionStyleNone;
            cell.backgroundColor=[UIColor clearColor];      


            //  UIView *viewDescription = [[UIView alloc]initWithFrame:CGRectMake(00, 00, 480, 35)];

            //////////////////////    Labels for description of city events from database  ////////////////////////////             

            UILabel *lblEvent = [[UILabel alloc]initWithFrame:CGRectMake(15, 00, 150, 30)];
            lblEvent.font = [UIFont systemFontOfSize:12];
            lblEvent.backgroundColor = [UIColor clearColor];

            UILabel *lblEventAtDate = [[UILabel alloc]initWithFrame:CGRectMake(200, 00, 150, 30)];
            lblEventAtDate.font = [UIFont systemFontOfSize:12];
            lblEventAtDate.backgroundColor = [UIColor clearColor];

            UILabel *lblEventAtSchool = [[UILabel alloc]initWithFrame:CGRectMake(350, 15, 150, 30)];
            lblEventAtSchool.font = [UIFont systemFontOfSize:12];
            lblEventAtSchool.backgroundColor = [UIColor clearColor];

            [cell.contentView addSubview:lblEvent];
            [cell.contentView addSubview:lblEventAtDate];
            [cell.contentView addSubview:lblEventAtSchool];


            lblEvent.text = data.EventName;
            //  lblEventAtDate.text = data.EventDate;
            lblEventAtSchool.text = data.EventPlace;
        }



        //} 
    }
}


// Configure the cell...

return cell;
}
  • 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-24T19:44:39+00:00Added an answer on May 24, 2026 at 7:44 pm

    As a first thing, I moved everything out of cell == nil block, as reuse may not happen. See if this solves your problem.

    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
    
    {    
    
    NSString *CellIdentifier = [@"" stringByAppendingFormat:@"Cell%d",indexPath.row];      
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    cell.backgroundColor = [UIColor clearColor];
    
    if(requestType == 2)
    {   
        if (cell == nil)
        {
            cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
    
            //  for (int j = 0 ; j < [self.arrayEventDescription count]; j++)
    
            //  for(int j=0; j<[tableView numberOfSections]; j++)
    
            //{
    
            NSLog(@"at section %d",indexPath.section);
            NSLog(@"at row %d",indexPath.row);
            NSLog(@"array count %d",[self.arrayEventDescription count]);
    
    
    
    
    
            //} 
        }
    
        if (indexPath.row < [self.arrayEventDescription count]) 
        {
    
    
            EventData *data = [self.arrayEventDescription objectAtIndex:indexPath.row];
            //EventData *data = [self.arrayEventDescription objectAtIndex:j];
    
            cell.selectionStyle=UITableViewCellSelectionStyleNone;
            cell.backgroundColor=[UIColor clearColor];      
    
    
            //  UIView *viewDescription = [[UIView alloc]initWithFrame:CGRectMake(00, 00, 480, 35)];
    
            //////////////////////    Labels for description of city events from database  ////////////////////////////             
    
            UILabel *lblEvent = [[UILabel alloc]initWithFrame:CGRectMake(15, 00, 150, 30)];
            lblEvent.font = [UIFont systemFontOfSize:12];
            lblEvent.backgroundColor = [UIColor clearColor];
    
            UILabel *lblEventAtDate = [[UILabel alloc]initWithFrame:CGRectMake(200, 00, 150, 30)];
            lblEventAtDate.font = [UIFont systemFontOfSize:12];
            lblEventAtDate.backgroundColor = [UIColor clearColor];
    
            UILabel *lblEventAtSchool = [[UILabel alloc]initWithFrame:CGRectMake(350, 15, 150, 30)];
            lblEventAtSchool.font = [UIFont systemFontOfSize:12];
            lblEventAtSchool.backgroundColor = [UIColor clearColor];
    
            [cell.contentView addSubview:lblEvent];
            [cell.contentView addSubview:lblEventAtDate];
            [cell.contentView addSubview:lblEventAtSchool];
    
    
            lblEvent.text = data.EventName;
            //  lblEventAtDate.text = data.EventDate;
            lblEventAtSchool.text = data.EventPlace;
        }
    }
    
    
    // Configure the cell...
    
    return cell;
    

    }

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

Sidebar

Related Questions

I am working on a web application in Java which gets data from servlets
I'm working on an application which has data imported from a foreign (and wholly
I'm working on a data distribution application which receives data from a source and
I'm working on an application which accesses data from an Oracle 11g database. I'm
I'm working on an application which uses data from db which has to be
I am working on a Website which is displaying all the apps from the
I am working on an application which is used to scrape data from an
I'm working on an application which stores data in tables, similar to an RDBMS.
I am working on a content management application in which the data being stored
I'm working profesionally on a php web application which contains contacts, among other data.

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.