title: Objective C compare UIButton if(sender==button)
body: <p>Hey I am trying to get the button in the <code>UIControlEventTouchUpInside</code> listener. I used to do that with tags but I got sick of this now as I can do all that in Android simply by doing something like <code>arg0==button</code>.</p>
  
  <p>I set the selector like that</p>
  
  <pre><code>[button addTarget:self action:@selector(actionUp:) forControlEvents:UIControlEventTouchUpInside];
  </code></pre>
  
  <p>Then in this method</p>
  
  <pre><code>- (IBAction)actionUp:(id)sender
  {
  
      UIButton *b = (UIButton *)sender;
  
      if(b==button){
          NSLog(@"yeeeee");
      }
  }
  </code></pre>
  
  <p>nothing happens, the two objects <code>b</code> and <code>button</code> are almost the same but refer to another address in memory (like with 2 strings compared with ==).</p>
  
  <p><code>b</code> definitely gets the button right as I can do</p>
  
  <pre><code>[b setBackgroundImage:[UIImage imageNamed:@"image"] forState:UIControlStateNormal];
  </code></pre>
  
  <p>Which addresses the button right.</p>
  
  <p>So what can I do? </p>
  
  <p>EDIT: pasted the wrong methods, sorry for that (error still persists tho, I just renamed them quickly for the post)</p>
  
  <p>EDIT SOLVED: isEqual: worked for me. What's weird is that after rebooting even == worked again. I cleaned the project before but that didn't help, but restarting my Mac did 0o Thanks.</p>