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

查看:211
本文介绍了目标 - 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.

明显的起点是 NSTimer

还有 performSelector withDelay函数系列

最后,我有时候使用了一个很酷的扩展,延迟块

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

哦,还有一个 - 你也可以设置本地通知s

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

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

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