【发布时间】:2014-04-21 10:15:07
【问题描述】:
我有一个本地通知。像这样 ;
NSNumberFormatter *faturaSonOdemeGunuFormatter = [[NSNumberFormatter alloc] init];
[faturaSonOdemeGunuFormatter setNumberStyle:NSNumberFormatterNoStyle];
NSNumber *faturaSonOdemeGunuNumber = [faturaSonOdemeGunuFormatter numberFromString:_txtFaturaGunu.text];
NSDate *currentDate = [NSDate date];
NSCalendar * calendar = [NSCalendar currentCalendar];
[calendar setTimeZone:[NSTimeZone systemTimeZone]];
NSDateComponents* components = [calendar components:NSYearCalendarUnit|NSMonthCalendarUnit|NSDayCalendarUnit | NSHourCalendarUnit | NSMinuteCalendarUnit fromDate:currentDate];
[components setTimeZone:[NSTimeZone systemTimeZone]];
[components setHour:12];
[components setMinute:40];
[components setDay: faturaSonOdemeGunuNumber.integerValue -3];
NSDate *test = [calendar dateFromComponents:components];
// Schedule the notification
UILocalNotification* localNotification = [[UILocalNotification alloc] init];
localNotification.fireDate = test;
localNotification.alertBody = [NSString stringWithFormat:@"%@ Faturanıza 3 gün kaldı.",_txtFaturaAdi.text];
localNotification.alertAction = @"Faturayı göster";
localNotification.timeZone = [NSTimeZone systemTimeZone];
localNotification.applicationIconBadgeNumber = [[UIApplication sharedApplication] applicationIconBadgeNumber] + 1;
[[UIApplication sharedApplication] scheduleLocalNotification:localNotification];
// Request to reload table view data
[[NSNotificationCenter defaultCenter] postNotificationName:@"reloadData" object:self];
此代码不会重复。我想在 faturaSonOdemeGunuNumber integerValue 日每个月重复本地通知。它应该从 sonOdemeGunuNumber -3 开始(例如用户写 17。它应该从 14 开始)并且它应该在每个月发出通知直到 faturaSonOdemeGunuNumber 的一天。我的意思是它应该每天继续通知用户,直到选定的那一天。 我该怎么做?
谢谢!
【问题讨论】:
标签: ios objective-c nsdate uilocalnotification