Vignesh
Vignesh

Reputation: 10251

Notify app when iPad date time settings changed

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 mode is 12 or 24 hr format. NSDateFormatter is seems to take lots of time( seen in time profiling). So I would like to check use it only when settings is changed.

Upvotes: 3

Views: 6436

Answers (3)

Juraj Antas
Juraj Antas

Reputation: 2712

You may also want to listen to this notification: NSSystemTimeZoneDidChangeNotification

Upvotes: 0

Marco
Marco

Reputation: 6692

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

Upvotes: 7

Midhun MP
Midhun MP

Reputation: 107131

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

Upvotes: 15

Related Questions