I have a variable called "conteggio" in my code, you can see it below... this variable have to increase of 1 at every row of my tableview... when i try to do this i receive a result like: 4,8,12,16,etc. multiples of 4 for each row... it seems that it repeat the code 4 times for each row.
And if i scroll back and forth my table those numbers become multiples.
HERE IS MY CODE:
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cellID"];
if (cell == nil){
cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:@"cellID"] autorelease];
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"cellID"];
cell.selectionStyle = UITableViewCellSelectionStyleNone;
}
NSString *alphabet = [fevIndice objectAtIndex:[indexPath section]];
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"SELF beginswith[c] %@", alphabet];
NSArray *fv = [fev filteredArrayUsingPredicate:predicate];
conteggio++;
NSString *string = [NSString stringWithFormat:@"%d", conteggio];
cell.detailTextLabel.text = string;
if ([fv count]>0) {
NSString *cellValue = [fv objectAtIndex:indexPath.row];
cell.textLabel.text = cellValue;
//indexPath.section; //[fv count] numero di elementi in una section;
//cell.detailTextLabel.text = [fevMesi objectAtIndex:conteggio];
//cell.imageView.image = [UIImage imageNamed:[fevIcona objectAtIndex:]];
}
cell.detailTextLabel.numberOfLines = 3;
cell.detailTextLabel.font = [UIFont systemFontOfSize:11.0];
return cell;
}