title: Spacing/Margins between cells on UITableView with Custom UITableViewCell
body: <p>I have a custom UITableViewCell that I'm using in my TableView, but I want there to be spacing between each cell. The info that gets put into the cell is being grabbed from my database (I'm using Parse), so it's different every time. I found this great SO solution here: <a href="https://stackoverflow.com/questions/10761744/spacing-between-cells-on-uitableview-with-custom-uitableviewcell">Spacing between cells on UITableView with Custom UITableViewCell</a></p>
  
  <p>but the problem after I implemented the code from that question is that now my tableview only shows every other cell, it skips over info in my array and doesn't display it.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
  {
      if (indexPath.row % 2 == 1)
          return 40;
      return 73;
  
      //return 73;
  }
  
  - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath object:(PFObject *)object {
  
      //Begin
      static NSString *CELL_ID2 = @"SOME_STUPID_ID2";
      // even rows will be invisible
      if (indexPath.row % 2 == 1)
      {
          UITableViewCell * cell2 = [tableView dequeueReusableCellWithIdentifier:CELL_ID2];
  
          if (cell2 == nil)
          {
              cell2 = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault
                                             reuseIdentifier:CELL_ID2];
              [cell2.contentView setAlpha:0];
              [cell2 setUserInteractionEnabled:NO]; // prevent selection and other stuff
          }
          return cell2;
      }
  
      //End
  
      static NSString *CellIdentifier = @"debateCell";
  
      RipDebateTableCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
  
      if (cell == nil)
      {
          NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"RipDebateTableCell" owner:self options:nil];
          cell = [nib objectAtIndex:0];
      }
  
  
  
      // Configure the cell
      NSDateFormatter *df = [[NSDateFormatter alloc] init];
      //[df setLocale:enUSPOSIXLocale];
      [df setTimeZone:[NSTimeZone systemTimeZone]];
      [df setDateFormat:@"MMM dd, yyyy "];
      NSString *my = [df stringFromDate:[object objectForKey:@"Date"]];
      NSLog(@"%@", my);
      tableView.separatorInset = UIEdgeInsetsMake(0, 0, 0, 0);
      cell.titleOf.text = [object objectForKey:@"Topic"];
      cell.dateOf.text = [NSString stringWithFormat:@"Date: %@", my];
      cell.typeOf.text = @"Debate";
      cell.cellTop.image = [UIImage imageNamed:@"table-top"];
      //cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
      //cell.selectionStyle = UITableViewCellSelectionStyleNone;
  
      return cell;
  }
  </code></pre>
  
  <p>self.objects is the array in which the info from the database goes into. How can I make it so there is still spacing between cells, but no information in the array is skipped?</p>
  
  <p>EDIT: Here is the code that fetches the data</p>
  
  <pre><code>- (PFQuery *)queryForTable {
      PFQuery *query = [PFQuery queryWithClassName:self.parseClassName];
      //query whereKey:@"school" equalTo:[PFUser curr]
      [query whereKey:@"school" equalTo:[[PFUser currentUser]objectForKey:@"mySchool"]];
      // If no objects are loaded in memory, we look to the cache first to fill the table
      // and then subsequently do a query against the network.
      if ([self.objects count] == 0) {
          //[query whereKey:@"providerZipCode" equalTo:[NSNumber numberWithInt:78664]];
          NSLog(@"NONE");
          query.cachePolicy = kPFCachePolicyCacheThenNetwork;
      }
  
      [query orderByAscending:@"Date"];
  
      return query;
  }
  </code></pre>
  
  <p>This query adds the objects to self.objects, an array.</p>
  
  <p>If it is still unclear, here is a link to the Parse docs regarding the view controller: <a href="https://parse.com/docs/ios_guide#ui-tables/iOS" rel="nofollow noreferrer">https://parse.com/docs/ios_guide#ui-tables/iOS</a></p>