Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>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. </p> <p>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.</p> <pre><code>- (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; } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload