title: How to get the title for a UIButton when it is pressed
body: <p>I'm trying to discover what the UIButton title is for which UIButton was pressed in the following code.</p>
  
  <p>on viewDidLoad the button title is outputted to the console using:</p>
  
  <pre><code>        NSLog(@"The button title is %@ ", btn.titleLabel.text);
  </code></pre>
  
  <p>I would like to get this title when a button is pressed instead.</p>
  
  <p>thanks for any help</p>
  
  <p>:) </p>
  
  <pre><code>// Create buttons for the sliding category menu.
          NSMutableArray* buttonArray = [NSMutableArray array];
          NSArray * myImages = [NSArray arrayWithObjects:@"category-cafe-unsel.png", @"category-food-unsel.png", @"category-clothing-unsel.png", @"category-health-unsel.png", @"category-tech-unsel_phone.png" , @"category-tech2-unsel.png", @"catefory-theatre-unsel.png", @"category-travel-unsel.png", nil];
  
          // only create the amount of buttons based on the image array count
          for(int i = 0;i &lt; [myImages count]; i++)
          {
              // Custom UIButton
  
              btn = [UIButton buttonWithType:UIButtonTypeCustom];
  
              [btn setFrame:CGRectMake(0.0f, 20.0f, 52.0f, 52.0f)];
              [btn setTitle:[NSString stringWithFormat:@"Button %d", i] forState:UIControlStateNormal];
              [btn setImage:[UIImage imageNamed:[myImages objectAtIndex:i]] forState:UIControlStateNormal];
  
              NSLog(@"The button title is %@ ", btn.titleLabel.text);
  
              [btn addTarget:self action:@selector(buttonPressed:) forControlEvents:UIControlEventTouchUpInside];
              [buttonArray addObject:btn];
  
              NSLog(@"Button tag is: %d",btn.tag);
  
          }
  </code></pre>