Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- times = [[NSMutableArray alloc]initWithObjects:@"02:06 PM",@"2:17 PM", nil];
- for (NSString * arrDay in times) {
- NSDate *date = [NSDate date];
- NSCalendar *gregorian = [NSCalendar currentCalendar];
- NSDateComponents *dateComponents = [gregorian components:(NSDayCalendarUnit|NSMonthCalendarUnit|NSYearCalendarUnit) fromDate:date];
- NSInteger day = [dateComponents day];
- NSInteger month = [dateComponents month];
- NSInteger year = [dateComponents year];
- NSString * dayTime1=[NSString stringWithFormat:@"%li-%li-%li %@",(long)day,(long)month,(long)year,arrDay];
- NSDateFormatter* df = [[NSDateFormatter alloc] init];
- [df setLocale:[[NSLocale alloc] initWithLocaleIdentifier:@"en_US_POSIX"]];
- [df setTimeZone:[NSTimeZone defaultTimeZone"]];
- [df setDateFormat:@"dd-MM-yyyy hh:mm a"];
- NSDate* newDate = [df dateFromString:dayTime1];
- [df setDateFormat:@"dd-MM-yyyy HH:mm a"];
- [self scheduleNotificationForDate:newDate];
- -(void) scheduleNotificationForDate: (NSDate*)date {
- [[UIApplication sharedApplication] cancelAllLocalNotifications];
- UILocalNotification *localNotification = [[UILocalNotification alloc] init];
- localNotification.fireDate = date;
- localNotification.timeZone = [NSTimeZone defaultTimeZone];
- localNotification.alertBody = @"Your Notification Text";
- localNotification.alertAction = NSLocalizedString(@"View details", nil);
- NSLog(@"Notification will be shown on: %@ ",localNotification.fireDate);
- localNotification.soundName = UILocalNotificationDefaultSoundName;
- localNotification.applicationIconBadgeNumber = -1;
- [[UIApplication sharedApplication] scheduleLocalNotification:localNotification];
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement