Objective-C-在给定的时间/日期执行功能 [英] Objective-C - perform a function at given time/date

查看:97
本文介绍了Objective-C-在给定的时间/日期执行功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在给定的时间和日期调用一个函数?例如,我想在午夜存储某些变量的某些值(并将它们清除为零),以便可以将它们与前几天的值进行比较.

How might one get a function to be called at given time and date? For example, I would like to store some values of some variables at midnight (and clear them to zero) so they can be compared with the previous days values.

我如何在Objective-C中完成此任务?

How might I accomplish this in Objective-C?

谢谢

杰克

推荐答案

根据您的需求,您有很多选择.

You've got quite a few options, depending on what you're after.

明显的起点是还有 performSelector withDelay函数族.

最后,我有时会使用一个很酷的扩展名,延迟的块.

Lastly, a cool extension I sometimes use, delayed blocks.

哦,还有-您还可以设置

Oh, one more - you can also setup Local Notifications.

这篇关于Objective-C-在给定的时间/日期执行功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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