目標日から 2 日前に通知を送信したい.現在、以下のコードを使用して通知を送信していますが、目標日から 2 日前に通知を送信する方法があります。
NSString *frstdate = [[calenderarray objectAtIndex:k] objectForKey:@"date"];
NSLog(@"frstdate..%@",frstdate);
NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init];
[dateFormat setDateFormat:@"yyyy-MM-dd"];
NSDate *date = [dateFormat dateFromString:frstdate];
NSLog(@"date..%@",date);
NSDate *dateToFire = [[[NSDate alloc] initWithTimeInterval:-24*60*60 sinceDate:date]autorelease];
NSLog(@"dateToFire..%@",dateToFire);
UILocalNotification *localNotif = [[UILocalNotification alloc] init];
if (localNotif == nil)
return;
localNotif.fireDate = itemDate;
localNotif.alertAction = @"View";
localNotif.soundName = UILocalNotificationDefaultSoundName;
localNotif.applicationIconBadgeNumber = 1;
localNotif.userInfo = [NSDictionary dictionaryWithObjectsAndKeys:[NSString stringWithFormat:@"Get Food"], @"foodItem", nil] ;
[[UIApplication sharedApplication] scheduleLocalNotification:localNotif];
[localNotif release];
Thanks in advance.