处理被“延后"的邮件的好方法是什么?功能? [英] What would be a good way to handle "snoozed" functions?

查看:224
本文介绍了处理被“延后"的邮件的好方法是什么?功能?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

到目前为止,我已经尝试了几种解决方案,但不确定是否有正确"的方法.我正在使用具有贪睡功能的待办事项清单.当我需要运行一个函数以将其移至其他列表时,每个任务都有一个从贪睡中醒来"的时间.

I've tried a few solutions so far but I'm not sure if there is a "right" way. I'm working on a todo list with a snooze function. Each task has a "wake from snooze" time when I need to run a function to move it into a different list.

我尝试遍历每个任务,并在viewWillAppear和/或viewDidAppear运行时移动它.这通常可以正常工作,但似乎偶尔会失灵,并且在应用程序运行且用户未切换视图时不会发生.

I've tried looping through each task and moving it when viewWillAppear and/or viewDidAppear runs. This generally works but seems to misfire occasionally and wouldn't happen while the app is running and the user isn't switching views.

我尝试使用Timer()函数在实际的特定时间移动项目,该时间仅在应用程序运行时有效.

I've tried using the Timer() function to move items at the actual specific times which only works while the app is running.

我尝试使用performFetchWithCompletionHandler在后台移动项目并每小时检查一次.

I've tried moving the items in the background using performFetchWithCompletionHandler and checking every hour.

还有什么我应该尝试使此运行更平稳吗?这是所有这些的结合吗?如果是这样,我如何确保我不会尝试同时移动两次物品?

Anything else I should try to make this run more smoothly? Is it a combination of all of these? If that's the case, how would I make sure that I'm not trying to move items twice at the same time?

推荐答案

通常,问题似乎是如何确保在特定日期时间发生某些事情.

In general the question seems to be how to ensure that something happens at a certain date-time.

  1. 计算出目标日期时间,然后将其记录在稳定的位置(文件,用户默认值等)以及随后发生的情况.

  1. Work out what the target date-time is and write it down somewhere stable (a file, user defaults, whatever) along with what has to happen then.

观看时钟.每分钟触发一次的计时器可能就足够了.只要看看时钟,看看时间是否过去了.如果有的话,请执行该操作并清除信息,指出该操作需要在该日期时间发生.

Watch the clock. A timer that fires every minute will probably be good enough; just look at the clock and see if that time has passed. If it has, do the thing and erase the info saying that this thing needs to happen at this date-time.

如果应用进入后台,请停止计时器.

If the app goes into the background, stop the timer.

当应用再次出现在前台时,请检查您的日期时间.

When the app comes to the foreground again, check your date-time.

  • 如果时间已过去,请执行该操作并清除信息,指出该操作必须在该日期时间发生.

  • If the time has passed, do the thing and erase the info saying that this thing needs to happen at this date-time.

如果没有,请重新启动计时器并继续观察时钟.

If not, start the timer again and keep watching the clock.

这篇关于处理被“延后"的邮件的好方法是什么?功能?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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