title: Using sender to identify object that called method in ios
body: <p>I'm new at this so thanks in advance for any help here.</p>
  
  <p>I'm just playing around with a little exercise in iOS and I have 2 different things calling the same routine.</p>
  
  <p>Each of these message calls passes along sender. One of these is a <code>UIButton</code> that calls when <code>touchUpInside</code>, one is a <code>UISegmentedControl</code> that calls when <code>valueChanges</code>.</p>
  
  <p>I need to handle the initial part slightly differently within the same method and i know that somehow I use sender.</p>
  
  <p>What I need to do is to ask if sender is a <code>UIButton</code> or if sender is a <code>UISegmentedControl</code>.</p>
  
  <p>I tried</p>
  
  <pre><code>if  ([sender isKindOfClass:UISegmentedControl]) { ... }
  </code></pre>
  
  <p>And</p>
  
  <pre><code>if ([sender isKindOfClass:UIButton]) { ... }
  </code></pre>
  
  <p>Both throw up an error along like this one:</p>
  
  <p><code>Unexpected interface name "UIButton": expected expression</code></p>
  
  <p>So that's obviously wrong.</p>