title: Handle button event in UITableviewcell
body: <p>I am trying to get a number from an array and store it in a button in UITableview cell. When I tap the button,  I should be able to get the number. Whats the right way to get the information from the sender in the button click event</p>
  
  <p>This is what I tried.</p>
  
  <pre><code>- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  {
   UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
  
  if (cell == nil )
  {
      UIButton *button = [[[UIButton alloc]init]autorelease];
      CGRect frame = CGRectMake(180, 10, 33, 33);
      button.frame = frame;
      button.tag = 1001;
  
      UIImage *image = [[[UIImage alloc]init]autorelease];
      image = [UIImage imageNamed:@"icon.png"];
      [button setBackgroundImage:image forState:UIControlStateNormal];
  
      [button addTarget:self action:@selector(onIconTapped)  forControlEvents:UIControlEventTouchUpInside];
      button.backgroundColor = [UIColor clearColor];
      [button setHidden:YES];
      cell.accessoryView = button;  
  
  }
  
  int myContactID = contact.contactID;
  NSLog(@"My No.  %d", myContactID);
  NSNumber *mySelectedNumber = [NSNumber numberWithInt:myContactID];
  
  UIButton *myButton = (UIButton *)[cell.accessoryView viewWithTag:1001];
  for(int i = 0; i&lt; [myContactsArray count]; i++){
      if([[[myContactsArray objectAtIndex:i]valueForKey:@"RecordID"] isEqualToNumber:mySelectedNumber]){
  
          [myButton setHidden:NO];
          NSString *myString;
          myString = [[myContactsArray objectAtIndex:i]valueForKey:@"MYNumber"];
          [myButton setTitle:myString forState:UIControlStateNormal];
          myButton.titleLabel.font = [UIFont systemFontOfSize:0];
          NSLog(@"my number %@", myString);
          NSLog(@"Button tag %@", myButton.currentTitle);
          break;
      }
      else{
         [myButton setHidden:YES];
      }
  }
  }
  
  
  
  -(void)onIconTapped:(id)sender{
  }
  </code></pre>