
Untitled
By: a guest on
Jun 4th, 2012 | syntax:
Objective C | size: 2.50 KB | hits: 38 | expires: Never
-(NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section {
return (isGrouped && searchBar.text.length == 0 ? [groupNames objectAtIndex:section] : nil);
}
-(NSInteger)tableView:(UITableView *)tableView sectionForSectionIndexTitle:(NSString *)title atIndex:(NSInteger)index{return (isGrouped && searchBar.text.length == 0 ? [groupNames indexOfObject: [groupsFastAccess objectForKey:title]] : 0);}
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{return (isGrouped == YES && searchBar.text.length == 0 ? [groupNames count] : 1);}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{return (searchBar.text.length == 0 ? (isGrouped ? [[groupedData objectForKey:[groupNames objectAtIndex:section]] count] : [arrayData count]) : [filteredData count]);}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
[tableView deselectRowAtIndexPath:indexPath animated:true];
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];
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{return [delegate heightsOfRowInSoGeViewTable:self];}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
NSString * key = [NSString stringWithFormat:@"%d_%d", indexPath.section, indexPath.row];
UITableViewCell * cellElement = [cells objectForKey:key];
if(cellElement == NULL)
{
if(delegate)
{
SoGeViewTableControllerCell * cell = [delegate cellForSoGeViewTable:self];
//[cell setDataBase:((AppDelegate *)[[UIApplication sharedApplication] delegate]).dataBase];
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;
[cell setData: element];
[cell setEditMode: isEditMode];
cellElement = cell;
if([cells count] > 100) [cells removeAllObjects];
[cells setObject:cellElement forKey:key];
}
}
return cellElement;
}