1

我正在尝试在一天中的某个时间执行一项操作。

我不想使用UILocalNotification,因为如果发生任何事情,我不希望用户离开。

我目前的代码是:

[NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(fire:) userInfo:nil repeats:NO];
4

1 回答 1

2

你可以:

  1. 每次您的应用开始使用[NSDate date]inapplication:didFinishLaunchingWithOptions方法时提取当前本地时间。

  2. 使用计算警报时间的剩余时间dateWithTimeInterval:sinceDate

  3. 以. NSTimer_interval = that_time_difference

我不确定你是什么意思:

“我不希望用户远离任何发生的事情。”

我假设如果应用程序未运行,您不希望发生任何事情。我唯一能想到的就是推送通知。

于 2013-03-11T13:02:51.067 回答