更新时间:2023-02-26 21:13:57
我认为将你的fireDate设置为22:00在您想要获得通知的那一天(而不是从现在开始的一周)可以做您想要的。您可能希望使用 NSCalendar
来执行此操作。
I would think that setting your fireDate to 22:00 on the day you want to get the notification (rather than "a week from now") would do what you want. You'll probably want to use NSCalendar
to do that.
NSDateComponents *dateComponents = [[NSDateComponents alloc] init];
NSDate *currentDate = [NSDate date];
NSDate *fireDate = nil;
[dateComponents setDay:3]; // ...or whatever day.
[dateComponents setHour:22];
[dateComponents setMinute:0];
fireDate = [gregorian dateByAddingComponents:dateComponents
toDate:currentDate
options:0];
[localNotification setFireDate:fireDate];
[dateComponents release];