title: How do I get the current date in Cocoa
body: <p>I'm getting started developing for the iPhone and as such I am looking at different tutorials online as well as trying some different things out myself. Currently, I'm trying to create a countdown until midnight. To get the number of hour, minutes, and seconds, I do the following (which I found somewhere):</p>
  
  <pre><code>NSDate* now = [NSDate date];
  
  int hour = 23 - [[now dateWithCalendarFormat:nil timeZone:nil] hourOfDay];
  int min = 59 - [[now dateWithCalendarFormat:nil timeZone:nil] minuteOfHour];
  int sec = 59 - [[now dateWithCalendarFormat:nil timeZone:nil] secondOfMinute];
  countdownLabel.text = [NSString stringWithFormat:@"%02d:%02d:%02d", hour, min,sec];
  </code></pre>
  
  <p>However, each place I use <code>-dateWithCalendarFormat:timeZone:</code> I get the following error:</p>
  
  <pre><code>warning: 'NSDate' may not respond to '-dateWithCalendarFormat:timeZone:'
  (Messages without a matching method signature will be assumed to return 'id' and accept '...' as arguments.)
  warning: no '-hourOfDay' method found
  error: invalid operands to binary - (have 'int' and 'id')
  </code></pre>
  
  <p>This seems like something very simple. What am I missing?</p>
  
  <p>Also, I've noticed at different places and at different times the asterisk (*) is located either right after the time <code>NSDate* now</code> or right before the variable <code>NSDate *now</code>. What is the difference in the two and why would you use one versus the other? </p>