Notify app when iPad date time settings changed

后端 未结 3 421
天涯浪人
天涯浪人 2020-12-14 13:28

I would like to get notified when ipad\'s date-time settings is changed. Is there any way for that?.

I am using NSDateFormatter to find whether iPad/iphone time mod

相关标签:
3条回答
  • 2020-12-14 14:16

    How about adding an observer for NSCurrentLocaleDidChangeNotification ? Per Apple, "Re-create any cached date and number formatter objects whenever the current locale information changes."

    0 讨论(0)
  • 2020-12-14 14:23

    You may also want to listen to this notification: NSSystemTimeZoneDidChangeNotification

    0 讨论(0)
  • 2020-12-14 14:25

    You can do it using two ways:

    1. Implement - (void)applicationSignificantTimeChange:(UIApplication *)application in your app delegate.
    2. Add a observer for UIApplicationSignificantTimeChangeNotification

      [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(timeChanged:) name:UIApplicationSignificantTimeChangeNotification object:nil];

    applicationSignificantTimeChange:

    Tells the delegate when there is a significant change in the time. - (void)applicationSignificantTimeChange:(UIApplication *)application

    Parameters

    application

    The delegating application object.
    

    Discussion

    Examples of significant time changes include the arrival of midnight, an update of the time by a carrier, and the change to daylight savings time. The delegate can implement this method to adjust any object of the application that displays time or is sensitive to time changes.

    Prior to calling this method, the application also posts a UIApplicationSignificantTimeChangeNotification notification to give interested objects a chance to respond to the change.

    If your application is currently suspended, this message is queued until your application returns to the foreground, at which point it is delivered. If multiple time changes occur, only the most recent one is delivered. Availability

    Available in iOS 2.0 and later.
    

    Declared In UIApplication.h

    For more check UIApplicationDelegate_Protocol

    0 讨论(0)
提交回复
热议问题