特定日期和时间的火灾行动 iPhone
在我的核心数据模型中,我有一个具有日期属性的实体。例如,我将此日期设置为 10/07/2011 4:00pm,并且我想在当前日期将超过保存的日期一分钟时触发操作。
将触发本地通知,但我还想触发另一个方法来更改另一个实体属性的值。可以做这样的事情吗?
我也想过 NSTimer,但我从未使用过它们...最后一个问题:即使应用程序不在后台或前台,此操作也会始终触发吗?
非常感谢!
马泰奥
in my Core Data model, I have an entity which has got a date attribute. For example, I'll set this date to 10/07/2011 4:00pm and I want to fire an action when current date will pass the saved date by one minute.
A local notification will be fired but I also want to fire another method to change another entity attribute's value. Is it possible to do something like this?
I've also thought to NSTimer but I've never used them... And a last question: will this action fire always even is app isn't in background or foreground?
Thank you so much!
Matteo
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
除了通过本地通知之外,您无法在后台模式下运行时触发操作。
要检查在前台运行时是否满足日期条件,可以使用 NSTimer。
You can't fire an action while running in background mode other than through local notifications.
To check if the date condition has been met while running in foreground,
NSTimer
is the way to go.尝试检查 本地通知
Try to check Local notifications