title: NSDate finding nearest date to today
body: <p>I have a sorted array of NSDates. Can someone help with how I can find the date in the array that is closest to the current date?</p>
  
  <p>I need to get the index of the date closest so that I can scroll to that date in my tableview.</p>
  
  <p>For example, if I have Jan 1 2013, Jan 6 2013, Jan 9 2013 and Jan 10 2013.  I want the index of Jan 6 2013.</p>
  
  <p>Hope that makes sense. Thanks for the help.</p>
  
  <p>UPDATE:</p>
  
  <p>I am trying this:</p>
  
  <pre><code>    NSTimeInterval interval = 0;
      NSUInteger indexOfDate;
      for (NSDate * date in m_arEventsSorted)
      {               
          if(abs([date timeIntervalSinceDate:[NSDate date]]) &lt; interval)
          {
              interval = abs([date timeIntervalSinceDate:[NSDate date]]);
              indexOfDate = [m_arEventsSorted indexOfObject:date];
          }
      }
  </code></pre>