title: What's the fastest way to switch between a zero and non-zero integer value in Objective-C?
body: <p>I have an integer "myInt" in some Objective-C code.  myInt is used as a boolean... hence I'm only interested in zero or non-zero values.  I'd like to quickly switch between zero and a non-zero value.  What's the fastest way to do this?  </p>
  
  <p>Here's what I've tried so far:  (All of these work)</p>
  
  <p><strong>Try 1</strong>:</p>
  
  <pre><code>// myInt is initialized to 0
  if(myInt == 0){
      myInt = 1;
  }else{
      myInt = 0;
  }
  </code></pre>
  
  <p><strong>Try 2</strong>:</p>
  
  <pre><code>myInt = !myInt;
  </code></pre>
  
  <p><strong>Try 3</strong>:</p>
  
  <pre><code>myInt ^= 0xffffffff;
  </code></pre>
  
  <p>I realize I could just measure the performance with a profiler... however I decided to ask on SO because I hope that others (any myself) can learn something from the discussion motivated by this question.</p>