【发布时间】:2012-11-26 10:07:10
【问题描述】:
对于我的应用,我不希望通知在周末关闭。
所以我的想法是在星期五的特定时间取消所有通知,我想通过安排任务来做到这一点,就像我安排通知一样(UILocalNotifications)
例如,我的闹钟有以下代码:
NSDateComponents *comps = [[NSDateComponents alloc] init];
[comps setHour:8];
[comps setMinute:25];
NSCalendar *gregorian = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
NSDate *fireDate = [gregorian dateFromComponents:comps];
UILocalNotification *alarm = [[UILocalNotification alloc] init];
alarm.fireDate = fireDate;
alarm.repeatInterval = NSDayCalendarUnit;
alarm.soundName = @"sound.aiff";
alarm.alertBody = @"Message..";
alarm.timeZone = [NSTimeZone defaultTimeZone];
[[UIApplication sharedApplication] scheduleLocalNotification:alarm];
有没有办法用同样的方法取消所有通知,还是苹果不允许这样做?
【问题讨论】:
标签: iphone objective-c ios uilocalnotification nsdatecomponents