title: Waiting for a specified duration in Cocoa
body: <p>Is there a more straightforward way to wait for a specific amount of time in Cocoa than what I have come up with below?</p>
  
  <pre><code>- (void) buttonPressed {
      [self makeSomeChanges];
  
      // give the user some visual feedback and wait a bit so he can see it
      [self displayThoseChangesToTheUser];
      [self performSelector:@selector(buttonPressedPart2:) withObject:nil afterDelay:0.35];
  }
  
  - (void) buttonPressedPart2: (id)unused {
      [self automaticallyReturnToPreviousView];
  }
  </code></pre>
  
  <p>Just to be clear, there is no <b>functional</b> problem with this code -- my only beef is a <b>stylistic</b> one.  In my case the flow is simple enough that it works, but try to encapsulate it or throw in some conditionals and things could turn ugly.  It's been kind of nagging at me that I couldn't find a way to wait and then return to that same point in code like this (fictitious) example:</p>
  
  <pre><code>- (void) buttonPressed {
      [self doStuff];
      [UIMagicUnicorn waitForDuration:0.35];
      [self doStuffAfterWaiting];
  }
  </code></pre>