Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jun 4th, 2012  |  syntax: Objective C  |  size: 2.50 KB  |  hits: 38  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. -(NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section {
  2.     return (isGrouped && searchBar.text.length == 0 ? [groupNames objectAtIndex:section] : nil);
  3. }
  4. -(NSInteger)tableView:(UITableView *)tableView sectionForSectionIndexTitle:(NSString *)title atIndex:(NSInteger)index{return (isGrouped && searchBar.text.length == 0 ? [groupNames indexOfObject: [groupsFastAccess objectForKey:title]] : 0);}
  5.  
  6. -(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{return (isGrouped == YES && searchBar.text.length == 0 ? [groupNames count] : 1);}
  7. -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{return (searchBar.text.length == 0 ? (isGrouped ? [[groupedData objectForKey:[groupNames objectAtIndex:section]] count] : [arrayData count]) : [filteredData count]);}
  8. -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
  9. {
  10.     [tableView deselectRowAtIndexPath:indexPath animated:true];
  11.     if(delegate && [((id)delegate) respondsToSelector:@selector(SoGeViewTable:didSelectRow:atIndexPath:)])[delegate SoGeViewTable:self didSelectRow:[cells objectForKey:[NSString stringWithFormat:@"%d_%d", indexPath.section, indexPath.row]] atIndexPath:indexPath];
  12. }
  13. -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{return [delegate heightsOfRowInSoGeViewTable:self];}
  14. -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  15. {
  16.     NSString * key = [NSString stringWithFormat:@"%d_%d", indexPath.section, indexPath.row];
  17.     UITableViewCell * cellElement = [cells objectForKey:key];
  18.    
  19.     if(cellElement == NULL)
  20.     {
  21.         if(delegate)
  22.         {
  23.             SoGeViewTableControllerCell * cell = [delegate cellForSoGeViewTable:self];
  24.             //[cell setDataBase:((AppDelegate *)[[UIApplication sharedApplication] delegate]).dataBase];
  25.            
  26.             NSMutableDictionary * element = ((SoGeTableControllerElement *)(searchBar.text.length == 0 ? (isGrouped ? [[groupedData objectForKey:[groupNames objectAtIndex:indexPath.section]] objectAtIndex:indexPath.row] : [arrayData objectAtIndex:indexPath.row]) : [filteredData objectAtIndex:indexPath.row])).data;
  27.             [cell setData: element];
  28.             [cell setEditMode: isEditMode];
  29.             cellElement = cell;
  30.             if([cells count] > 100) [cells removeAllObjects];
  31.             [cells setObject:cellElement forKey:key];
  32.         }
  33.     }
  34.     return cellElement;
  35. }