确定是否发生日更改 [英] Determine if day change has occurred

查看:109
本文介绍了确定是否发生日更改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想创建一个每当新的一天发生在本地(无论是在使用应用程序,或者如果发生在发射之间)发生的消息。

I would like to create a notifciation that occurs every time a new day has occurred locally (either while using the app, or if it occurs in between launches). I was wondering what might be the best way to go about observing this change.

推荐答案

当应用程序运行时,您可以监听适用于 UIApplicationSignificantTimeChangeNotification 通知,并测试当天您收到。当您的应用程式退出时,您可以将偏好设定储存为目前的日期,而当应用程式重新启动时,您可以测试当天的储存天数。

While your app is running, you can listen for the UIApplicationSignificantTimeChangeNotification notification and test the current day when you receive that. When your app quits, you can save the current day to your preferences, and when the app launches again, you can test the saved day against the current day.

使用 NSDateComponents 。

这篇关于确定是否发生日更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆