- (UITableViewCell *)tableView:(UITableView *)tableView 
   cellForRowAtIndexPath:(NSIndexPath *)indexPath 
{
   static NSString *CellIdentifier = @"Cell";

   UITableViewCell *cell = [tableView 
      dequeueReusableCellWithIdentifier:CellIdentifier];

   if (cell == nil) {
      cell = [[[UITableViewCell alloc] 
         initWithStyle:UITableViewCellStyleSubtitle 
         reuseIdentifier:CellIdentifier] autorelease];
   }

   RentalProperty *details = &properties[indexPath.row]; 

   int indexOfComma = [details->address rangeOfString:@","].location;  
   NSString *address = [details->address 
      substringToIndex:indexOfComma]; 
   NSString *city = [details->address 
      substringFromIndex:indexOfComma + 2]; 

   cell.textLabel.text = address;

   if ([city isEqual:@"Clifton"]) 
      cell.imageView.image = [UIImage imageNamed:@"mountain.png"];
   else if ([city isEqual:@"Sumner"])
      cell.imageView.image = [UIImage imageNamed:@"sea.png"];
   else
      cell.imageView.image = [UIImage imageNamed:@"city.png"];

   cell.detailTextLabel.text =
      [NSString stringWithFormat:@"Nieruchomości za %0.2f zł tygodniowo",
         details->weeklyRentalPrice]; 
   return cell;
}
