title: UITableviewController - Update specific Cells
body: <p>I have created custom cells with a button that changes the state of a row from "availible" to "bought", and I also have an UIImageview which shows the state. I want the cell to redraw with the new state when the user presses the button.</p>
  
  <p>I have been able to get the UIImage to be redrawn after the User scrolls the cell out of view. This is what I have so far:</p>
  
  <p>Initialization</p>
  
  <pre><code>- (void)viewDidLoad
  {
    [super viewDidLoad];
    self.clearsSelectionOnViewWillAppear = YES;
    self.contentSizeForViewInPopover = CGSizeMake(600.0, 560.0);
    //[self.tableView setSeparatorStyle:UITableViewCellSeparatorStyleNone]; 
    [self.tableView setRowHeight:60];
    [self.tableView setBackgroundColor:[UIColor blackColor]];
  }
  </code></pre>
  
  <p>Got only one section:</p>
  
  <pre><code>- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
  {
    // Return the number of sections.
    return 1;
  }
  </code></pre>
  
  <p>And all items are in the "paketListe" array:</p>
  
  <pre><code>- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
  {
    // Return the number of rows in the section.
    return [paketListe count];
  }
  </code></pre>
  
  <p>The cellForRow function only gets called, when the cell is out of view and when the cell is initially drawn.</p>
  
  <pre><code>- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  {
    NSLog(@"CellForRow called!");
    PaketTableViewCell *cell = [[[PaketTableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:nil] autorelease];
    [cell setDelegate:self];
    Paket *tempPaket = [paketListe objectAtIndex:[indexPath row]];
    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *userDocumentsPath = [paths objectAtIndex:0];
    NSString *fileName = [NSString stringWithFormat:@"%@/%@/%@",userDocumentsPath, [tempPaket productID], [tempPaket previewPic]];
    [cell setProductIndex:[indexPath row]];
    //... Setting some Attributes in my custom cell, cut out for simplicity....
    cell.backgroundColor = [UIColor clearColor];
    return cell;
  }
  </code></pre>
  
  <p>The code for the Button, this is a delegate call, so my custom sell calls [delegate buttonPushed:(int)];</p>
  
  <pre><code>- (void) buttonPushed:(int) myProductIndex {
    NSLog(@"Pushed: %@", [[paketListe objectAtIndex:myProductIndex] productID]);
    CoreDataWrapper *tempCDW = [[CoreDataWrapper alloc] init];
    [tempCDW initCoreData];
    Paket *tempPaket = [paketListe objectAtIndex:myProductIndex];
    //Doing some work in Core Data an my "paketListe" array. Left out for simplicity... 
    [tempCDW release];
    //Here it begins....
    [[self tableView] reloadData];
    [[self tableView] beginUpdates];
    [[self tableView] reloadRowsAtIndexPaths:[NSArray arrayWithObject:[NSIndexPath indexPathForRow:myProductIndex inSection:0]] withRowAnimation:UITableViewRowAnimationFade];
    [[self tableView] endUpdates];
  }
  </code></pre>
  
  <p>Now I tried the reloading with different commands... Reload the whole thing with just <code>reloadData</code> or the <code>begin-/endUpdate</code> thing. Nothing refreshes the cell. After several hours of reading I think I did everything right, but no refresh.</p>
  
  <p>I appreciate any help.</p>