Sunil Targe
Sunil Targe

Reputation: 7459

How do I know if day is changed in iPhone date calender?

As I know, we can identify if time is changed in iPhone settings by using this method

- (void)applicationSignificantTimeChange:(UIApplication *)application

but I want lines which will fire condition if day is changed.

e.g Today is 10 Mar 2014, but later if I physically changed day like 11 Mar from my iPhone setting, then I wanted to know the same in above method.

Anyone please help.

Thanks in advance.

Upvotes: 0

Views: 334

Answers (2)

Clafou
Clafou

Reputation: 15400

I just tried it, and UIApplicationSignificantTimeChangeNotification does fire when you manually change the date through system settings–not just when the date changes after midnight.

So you don't need to do anything more for manual date changes, applicationSignificantTimeChange will be called.

And if you really need to enforce that action is taken only if the date does change, then of course you can store the date that you were last aware of and do a comparison in your implementation of applicationSignificantTimeChange to prevent unneeded execution if, for some reason, the event fired but the date hasn't actually changed.

Upvotes: 0

rmaddy
rmaddy

Reputation: 318824

I would suggest that you save off the current date each time your app starts and each time your app becomes inactive or goes into the background.

Then when applicationSignificantTimeChange: is called, check the current date with the saved date to see if the day has changed.

Upvotes: 1

Related Questions