Code:
-(void)viewWillDisappear:(BOOL)animated
{
NSCalendar *calendar = [NSCalendar currentCalendar];
NSDateComponents *components = [[NSDateComponents alloc] init];
[components setDay: 3];
[components setMonth: 7];
[components setYear: 2012];
[components setHour: 21];
[components setMinute: 21];
[components setSecond: 30];
[calendar setTimeZone: [NSTimeZone defaultTimeZone]];
NSDate *dateToFire = [calendar dateFromComponents:components];
UILocalNotification *noti =[[UILocalNotification alloc] init];
noti.fireDate = dateToFire;
noti.repeatInterval = kCFCalendarUnitDay;
noti.soundName = @"chun.aiff";
noti.alertBody = [NSString stringWithFormat:@"Personal balance: %i", -PB];
[[UIApplication sharedApplication] scheduleLocalNotification:noti];
}
The flaw:
If I’m right, I’d say that once this local notification is “embedded” into the device’s memory, it sticks with every local notification which has been created. I’m I right? If this is true, how can I manage this situation?
The notification alert is being repeated because you have used:
Your notification alert is scheduled only for the date you set using date to fire, but the alert is repeated on a day interval as you have set.
Set it to nil if you don’t want it to repeat.
Hope it solves your problem.
🙂