在一周中的某几天重复UILocalNotification

我想定制一个UILocalNotification的重复间隔在一周的某些天。 我还没有find任何有关这方面的信息。

如何在一周中的某些特定date中设置通知的重复时间间隔,例如,星期日,星期一和星期五重复通知?

不幸的是,您不能将UILocalNotificationrepeatInterval属性设置为仅在特定date重复。 您可以设置每天(每天),每月(每月)或每小时(每小时)重复一次。 所以对于你的问题唯一可行的解​​决scheme是,如果你想在周日,周一和周二设置闹钟,那么你必须设置3个闹钟(周日,周一和周二各一个)而不是一个闹钟。

如果您需要自定义repeatInterval属性。 你必须在指定的时间设置每个UILocalNotification 。 这里是我的代码。

 void (^insertAlarm)(NSDate*fire,NSString*sound,int alarmCount) = ^(NSDate*fire,NSString*sound,int alarmCount){ UILocalNotification* notification = [[UILocalNotification alloc] init]; notification.timeZone = [NSTimeZone defaultTimeZone]; notification.soundName = sound; notification.fireDate = fire; notification.repeatInterval = 0; notification.alertLaunchImage = IMG; notification.alertAction = ACTION_MSG; notification.alertBody = BODY; notification.applicationIconBadgeNumber = 1; [[UIApplication sharedApplication] scheduleLocalNotification:notification]; [notification release]; }; insertAlarm(date,sound.fileName,0); insertAlarm([date dateByAddingTimeInterval:60],sound.fileName,1);