i have in my app about 10 local notification (not in array )and its in switch. I used this code
NSUserDefaults *defaultsB = [NSUserDefaults standardUserDefaults];
UILocalNotification *notification = [[UILocalNotification alloc]init];
if (switcher.on == 1) {
NSCalendar *gregCalendar = [[NSCalendar alloc]initWithCalendarIdentifier:NSGregorianCalendar];
NSDateComponents *dateComponent = [gregCalendar components:NSYearCalendarUnit | NSWeekCalendarUnit fromDate:[NSDate date]];
[dateComponent setWeekday:1]; // For sunday
[dateComponent setHour:[timeHClass.text integerValue]];
[dateComponent setMinute:[timeMClass.text integerValue]];
NSDate *fireDate = [gregCalendar dateFromComponents:dateComponent];
[notification setAlertBody:textClass1.text];
[notification setFireDate:fireDate];
notification.soundName = @"bells.mp3";
notification.repeatInterval = NSWeekCalendarUnit;
[notification setTimeZone:[NSTimeZone defaultTimeZone]];
[[UIApplication sharedApplication] scheduleLocalNotification:notification];
[defaultsB setObject:@"ON" forKey:@"SwitchState"];
}
else {
UIApplication *app=[UIApplication sharedApplication];
[app cancelLocalNotification:notification];
[defaultsB setObject:@"OFF" forKey:@"SwitchState"];
}
but when i turned switch off the notification still working ??
should i save the notification save in NSUserDefaults not just the switch ??
and if its yes how ??