我想弄清楚如何在特定日期触发本地通知。
我必须使用日历单位,但我找到的有关它们的解释很烂。你们能给我解释一下吗,就好像我是五岁一样,它们代表什么间隔?
我已经填了我认为我知道的,如果我错了请指正并填写其他的。
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/