Question: I created some buttons in my code. I want to set it disable but I'm not sure how. here's my code.

```
UIButton *btn_levels = [UIButton    buttonWithType:UIButtonTypeRoundedRect];
btn_levels.frame=CGRectMake(x-10, y, 40, 40);
[btn_levels setTitle:[beginer_lvl objectAtIndex:i] forState:UIControlStateNormal];
[btn_levels addTarget:self action:@selector(btn_Method) forControlEvents:UIControlEventTouchUpInside];
btn_levels.tag =i;

btn_levels.backgroundColor=[UIColor blackColor];
btn_levels.tintColor=[UIColor cyanColor];

NSLog(@"btn nm=%@",[beginer_lvl objectAtIndex:i]);

[self.scroll addSubview:btn_levels];

```

and that is the button method but I don't know what to do...

```
-(void)btn_Method
{
    //to make button disable
}

```

Answer: 
Modify this line

```
[btn_levels addTarget:self action:@selector(btn_Method:) forControlEvents:UIControlEventTouchUpInside];

```

and this method

```
-(void)btn_Method:(UIButton*)sender
{
  sender.enabled = NO;
}

```
Target actions can send the object for which it'll performed the action. To make your method to know which button was tap, you need to make its definition to get the button inside the method. So just change you button definition to look like this,

```
- (void) btn_Method:(UIButton *)sender {...}

```

also, where you're adding target to the button you've to add a colon ( **:** ) *after the method name* to tell the compiler that, this action will need an object on which an action was added. So that line should look like this,

```
[btn_levels addTarget:self action:@selector(btn_Method:) forControlEvents:UIControlEventTouchUpInside];
                                                      ^

```

Here, we will get a `sender` (you can give any name to your argument) of type `UIButton` with btn\_Method action call. That's it, now you can do anything with that button, so in your case you want to make it disable, so the method would look like this,

```
- (void) btn_Method:(UIButton *)sender {
    sender.enabled = NO;
}

```