Advertisement
Guest User

core data section

a guest
Oct 7th, 2012
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. - (NSInteger)tableView:(UITableView *)table numberOfRowsInSection:(NSInteger)section {
  2.    
  3.    
  4.    
  5.     if (section == 0) {
  6.        
  7.         id <NSFetchedResultsSectionInfo> sectionInfo = [[self.fetchedResultsController sections] objectAtIndex:section];
  8.        
  9.         return [sectionInfo numberOfObjects];
  10.        
  11.     } else {
  12.        
  13.         return 1;
  14.     }
  15.    
  16.  
  17. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  18. {
  19.     static NSString *CellIdentifier = @"Category Cell";
  20.    
  21.     CategoryCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
  22.     if (cell == nil) {
  23.         cell = [[CategoryCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
  24.     }
  25.    
  26.     // Configure the cell...
  27.    
  28.     if (indexPath.section == 0) {
  29.        
  30.         NSLog(@"section %i",indexPath.section);
  31.        
  32.         Category *category = [self.fetchedResultsController objectAtIndexPath:indexPath];
  33.        
  34.        
  35.         cell.categoryNameLabel.text = category.name;
  36.         cell.categoryNumberItemsLabel.text = [NSString stringWithFormat:@"%i",category.containItem.count];
  37.        
  38.        
  39.     } else {
  40.        
  41.         NSLog(@"section 2");
  42.        
  43.         //Static cell
  44.        
  45.         cell.categoryNameLabel.text = @"ALL";
  46.        
  47.        
  48.        
  49.        
  50.     }
  51.    
  52.     return cell;
  53.    
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement