iphone - 了解 NSCalendar 单位(请像我五岁一样解释)

标签 iphone ios uilocalnotification

我想弄清楚如何在特定日期触发本地通知。

我必须使用日历单位,但我找到的有关它们的解释很烂。你们能给我解释一下吗,就好像我是五岁一样,它们代表什么间隔?

我已经填了我认为我知道的,如果我错了请指正并填写其他的。

NSEraCalendarUnit = ????? era? 
NSYearCalendarUnit = event will repeat once in a year at the same month, day and hour
NSMonthCalendarUnit = event will repeat once a month at the same day and hour
NSDayCalendarUnit = event will repeat every day at the same hour
NSHourCalendarUnit = event will repeat every hour at the same minute
NSMinuteCalendarUnit = event will repeat every minute at the same second
NSSecondCalendarUnit = event will repeat every second
NSWeekCalendarUnit = event will repeat the same day of week every week 
NSWeekdayCalendarUnit = ?????? can I make it repeat just specific days? I mean, monday to friday but not saturday and sunday?
NSWeekdayOrdinalCalendarUnit = ????? how do I use that?
NSQuarterCalendarUnit = when exactly will it repeat? every 3 months?
NSCalendarCalendarUnit = ?????????
NSTimeZoneCalendarUnit = ????????

这是我需要做的一个例子:

UILocalNotification* alarm = [[[UILocalNotification alloc] init] autorelease];
if (alarm)
{
    alarm.fireDate = aDate;
    alarm.timeZone = [NSTimeZone systemTimeZone];
    alarm.repeatInterval = WHAT DO I PUT HERE? TO MAKE IT REPEAT JUST SATURDAYS AND SUNDAYS?;
    alarm.soundName = @"alarm.caf";
    alarm.alertBody = @"hi there";
    [app scheduleLocalNotification:alarm];
}

我需要在这些可能性之一中对本地通知进行编程:

  • 从周一到周五每天触发,周六和周日除外
  • 每周六和周日触发,其他任何一天触发
  • 每周在同一天重复

我应该为 repeatInterval 使用什么值来完成这个?

谢谢

最佳答案

我相信你想要的是做不到的。 This question可能会提供更多细节。

当然,您可以做两个单独的本地通知,都设置为每周重复,一个在周六触发,一个在周日触发。

关于iphone - 了解 NSCalendar 单位(请像我五岁一样解释),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7441327/

相关文章:

c# - 嵌套的 C# 类 - 从内部调用外部方法

ios - React Native,应用程序在模拟器上运行,但不能在真实的 iPhone 上运行

ios - 使用 "PhoneGap Build"提交到 App Store 构建的 PhoneGap 应用程序

ios - 将设置为相同的本地通知限制为一个

ios - 什么是 UserNotification 框架相当于 didReceive 通知 : UILocalNotification?

ios - 前景和背景,哪些应用程序在哪里?

ios - 如何在不同的 UIViewController 之间传递数据?

iOS:如何在 WKWebView 中加载本地文件(不在 bundle 中)?

ios - iOS 版 Adob​​e Flash/Flex 与 MonoTouch 相比如何?

ios - UILocalNotification NSLocalizedString 使用设备的语言