获取即将到来的指定日期的日期

发布于 2024-12-08 19:11:15 字数 154 浏览 6 评论 0原文

我想安排 UILocal 通知,并希望它们在用户指定的特定日期重复。用户指定一个特定日期,然后指定他想要重复相同通知的日期。

我如何在用户选择后获取指定日期的日期。我知道我将不得不为此目的触发多个本地通知。

请帮助

谢谢,

阿迪亚

I want to schedule UILocal Notifications and want them to be repeated on particular days specified by the user.The user specifies a particular date and then specifies the days on which he wants to repeat the same notification.

How do i fetch the dates from the specified days after user selection.I know i will have to fire multiple local notifications for that purpose.

Please help

Thanks,

Aditya

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

初相遇 2024-12-15 19:11:15

不幸的是,UILocalNotification 对象的创建仅提供了在单个日历单元上重复出现的选项。例如,您可以设置每小时、每天或每个工作日等重复的通知。不花一点功夫就无法创建每周二和周四重复的通知。

话虽如此:您可以为每个 UILocalNotification 提供一个自定义的 NSDictionary,并将其分配给对象上的 userInfo 属性。如果我是你,我会创建一个自定义结构,其中包含有关通知的更多信息,并将其存储在字典中。如果您希望它简单,它可以只是一个包含 7 个布尔值的类,一个代表一周中的每一天。

例如,您可以创建一个每天重复的 UILocalNotification,使用上述结构,其星期二和星期四的布尔值为 YES,所有其他日期为 NO。

当您的本地通知触发,并且您通过以下方法响应它时:

-(void)application:(UIApplication *)application didReceiveLocationNotification:(UILocationNotification *)notification

您可以从通知中检索此 userInfo 字典,仔细查看底层重复,如果当天的布尔值为 则忽略通知不。

Unfortunately the creation of a UILocalNotification object only provides the option to recur on a single calendar unit. For example, you can have a notification that repeats every hour, or every day, or every weekday, etc. There is no way without a little effort to create a notification that repeats every Tuesday and Thursday.

That having been said: you can provide each UILocalNotification with a custom NSDictionary, assigned to the userInfo property on the object. If I were you, I would create a custom structure that contains a little bit more information about the notification, and store it in the dictionary. If you wanted it to be simple, it could just be a class containing 7 booleans, one for each day of the week.

As an example, you could create a UILocalNotification that repeats daily, with the above structure whose boolean values for Tuesday and Thursday are YES, and all other days are NO.

When your local notification fires, and you respond to it via the method:

-(void)application:(UIApplication *)application didReceiveLocationNotification:(UILocationNotification *)notification

You can retrieve this userInfo dictionary from the notification, take a closer look at the underlying repeat, and ignore the notification if the boolean value for the current day is NO.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文