title: how to change date when system hit midnight or user change time manual cocoa
body: <p>I have a problem with my calendar app for mac os x. i write the code and its work fine but as other part of code i want to change the icon of my app when system time hit midnight or user change the system date from system preferences. my code is like this for getting day from date :</p>
  
  <pre><code>- (int)dayNumber {
  
  NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
  NSDate *now = [NSDate date];
  
  NSCalendar *calendar = [[NSCalendar alloc]
                          initWithCalendarIdentifier:NSCalendarIdentifierPersian];
  dateFormatter.locale = [[NSLocale alloc] initWithLocaleIdentifier:@"fa_IR"];
  [dateFormatter setLocale:dateFormatter.locale];
  [dateFormatter setCalendar:calendar];
  [dateFormatter setDateFormat:@"d"];
  NSString *dayNum = [NSString stringWithFormat:@"%@", [dateFormatter stringFromDate:now]];
  int a = [dayNum intValue];
  
  NSLog(@"%i", a);
  return a;
  
  }
  </code></pre>
  
  <p>I'm returning an int value because in my other section i have function which have switch command that check this int to changing icon set.</p>
  
  <p>by the way if user change the day from system preferences when app is run and after that close the app and run the app again the app work just fine and detect the current day.</p>
  
  <p>how can i detect if system or user changing day so i can change my app day too.</p>