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

  • Home
  • SEARCH
  • 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 3788742
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T12:02:50+00:00 2026-05-19T12:02:50+00:00

I have displayed the datas in grouped table view. The data’s are displayed in

  • 0

I have displayed the datas in grouped table view. The data’s are displayed in the table view from XML parsing. I have 2 section of the table view, the section one has three rows and section two has two rows.

  section 1 ->  3 Rows

  section 2 - > 2 Rows.

Now i want to check, if anyone of the string is empty then i should remove the empty cells, so i have faced some problems, if i have removed any empty cell, then it will changed the index number. So how can i check, anyone of the field is empty?, Because some times more number of empty field will come, so that the index position will be change. So please send me any sample code or link for that? How can i achieve this?

Sample code,

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

 if (section == 0) {

    if([userEmail isEqualToString:@" "] || [phoneNumber isEqualToString:@" "] || [firstName isEqualToString:@" "])
    {
        return 2;

    } 

    else {

        return 3;

    }
}
if (section == 1) {

       if(![gradYear isEqualToString:@" "] || ![graduate isEqualToString:@" "]) {

    return 1;
}
    else
   {
        return 2;
     }


return 0;

}

Please Help me out!!!

Thanks.

  • 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-19T12:02:50+00:00Added an answer on May 19, 2026 at 12:02 pm

    As per my understanding, you dont want to add the row where data is empty, so ill suggest you should perpare the sections data before telling the table view about the sections and rows.

    So, may be following code can help you…, i have tested it you just need to call the method “prepareSectionData” from “viewDidLoad” method and define the section arrays in .h file.

    - (void) prepareSectionData {
     NSString *userEmail = @"";
     NSString *phoneNumber = @"";
     NSString *firstName = @"";
    
     NSString *gradYear = @"";
     NSString *graduate = @"";
    
     sectionOneArray = [[NSMutableArray alloc] init];
     [self isEmpty:userEmail]?:[sectionOneArray addObject:userEmail];
     [self isEmpty:phoneNumber]?:[sectionOneArray addObject:phoneNumber];
     [self isEmpty:firstName]?:[sectionOneArray addObject:firstName];
    
     sectionTwoArray = [[NSMutableArray alloc] init];
     [self isEmpty:gradYear]?:[sectionTwoArray addObject:gradYear];
     [self isEmpty:graduate]?:[sectionTwoArray addObject:graduate];
    }
    
     -(BOOL) isEmpty :(NSString*)str{
     if(str == nil || [[str stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]] length] == 0)
         return YES;
     return NO;
     }
    
      // Customize the number of sections in the table view.
    - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 2;
    }
    
    // Customize the number of rows in the table view.
    - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    if(section == 0){
        return [sectionOneArray count];
    } else if (section == 1) {
        return [sectionTwoArray count];
    }
    return 0;
    }
    
    
    // Customize the appearance of table view cells.
    
    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    
    
    static NSString *CellIdentifier = @"Cell";
    
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
    }
    
    // Configure the cell.
    if(indexPath.section == 0){
        cell.textLabel.text = [sectionOneArray objectAtIndex:indexPath.row];
    } else if (indexPath.section == 1) {
        cell.textLabel.text = [sectionTwoArray objectAtIndex:indexPath.row];
    }
    return cell;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a grouped tableview that is populated with XML data in one section.
Many applications have grids that display data from a database table one page at
I have a Data Grid View inside a control that is displayed in a
New to jQuery, I have a script that returns data from an XML file.
I have a data set whose elements are displayed as rows in a DataGrid.
I have a set of data that needs to be displayed as a crosstab
Let's say you have a form with a component that displays data from a
I have a grouped UITableView where not all sections may be displayed at once,
I have a UITableViewController managing a grouped tableView. The tableView is populated from a
I have a database where I store keywords grouped into projects and data related

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.