title: Difference in hours between two NSDate
body: <p>Here I'm trying to calculate the hours between two dates. When i run the application, it crashes. Could you please tell me the mistake in this code?</p>
  
  <pre><code>NSString *lastViewedString = @"2012-04-25 06:13:21 +0000";
  NSDateFormatter *dateFormatter = [[[NSDateFormatter alloc] init] autorelease];
  [dateFormatter setDateFormat: @"yyyy-MM-dd HH:mm:ss zzz"];
  
  NSDate *lastViewed = [[dateFormatter dateFromString:lastViewedString] retain];
  NSDate *now = [NSDate date];
  
  NSLog(@"lastViewed: %@", lastViewed); //2012-04-25 06:13:21 +0000
  NSLog(@"now: %@", now); //2012-04-25 07:00:30 +0000
  
  NSTimeInterval distanceBetweenDates = [now timeIntervalSinceDate:lastViewed];
  double secondsInAnHour = 3600;
  NSInteger hoursBetweenDates = distanceBetweenDates / secondsInAnHour;
  
  NSLog(@"hoursBetweenDates: %@", hoursBetweenDates);
  </code></pre>