gpt4 book ai didi

iphone - 这次如何从datePicker获取时间并运行方法?

转载 作者:可可西里 更新时间:2023-11-01 04:19:32 25 4
gpt4 key购买 nike

我想从datePicker中获取时间到NSDate对象中,然后在这段时间内每天运行一个方法。例如:用户在 datePicker 中放入了 08:00,应用程序将在每天 08:00 运行一些方法。

非常感谢,阿米尔·福格尔

最佳答案

要从日期选择器中获取时间,

NSDateFormatter *outputFormatter = [[NSDateFormatter alloc] init];
[outputFormatter setDateFormat:@"HH:mm"]; //24hr time format
NSString *dateString = [outputFormatter stringFromDate:self.myDatePicker.date];
[outputFormatter release];

在日常使用的特定时间执行功能 UILocalNotification .

将 repeatInterval 设置为 NSDayCalendarUnit。

并在处理 UILocalNotification 代码的委托(delegate)中编写您的方法。

注意:只有当用户接受本地通知时,该方法才会执行。

关于iphone - 这次如何从datePicker获取时间并运行方法?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6995466/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com