Change color of alternate row in UITableView for iPhone SDK

- (void)tableView: (UITableView*)tableView willDisplayCell: (UITableViewCell*)cell forRowAtIndexPath: (NSIndexPath*)indexPath
{
 
        if(indexPath.row % 2 == 0)
              cell.backgroundColor = [UIColor redColor];
        else
              cell.backgroundColor = [UIColor whiteColor];
}

use the indexPath in the cellForRowAtIndexPath to get the desired results.

    if( [indexPath row] % 2){
          cell.backgroundColor=[UIColor whiteColor];
    } 
    else{
          cell.backgroundColor=[UIColor purpleColor];
    }

You will have this delegate method in the class which is implementing the UITableViewDelegate