Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- NSDate *currentDate=[NSDate date];
- NSString *dateStr=@"6:32 PM";
- NSTimeZone *gmt = [NSTimeZone timeZoneWithAbbreviation:@"GMT"];
- NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
- [dateFormatter setDateFormat:@"hh:mm a"];
- [dateFormatter setTimeZone:gmt];
- [dateFormatter setDateFormat:@"yyyy-MM-dd"];
- NSString *preFix=[dateFormatter stringFromDate:currentDate];
- NSString *datetoFire=[NSString stringWithFormat:@"%@ %@",preFix,dateStr];
- [dateFormatter setDateFormat:@"yyyy-MM-dd hh:mm a"];
- NSLog(@"date is %@",[dateFormatter dateFromString:datetoFire]);
- [dateFormatter setDateStyle:NSDateFormatterShortStyle];
- [dateFormatter setTimeStyle:NSDateFormatterShortStyle];
- NSDate *fireDate = [dateFormatter dateFromString:datetoFire];
- // Cancel the previously scheduled notification, if any.
- if (localNotification != nil) {
- [[UIApplication sharedApplication] cancelLocalNotification:localNotification];
- localNotification.applicationIconBadgeNumber--;
- }
- NSLog(@"Fire date is %@",fireDate);
- // Schedule new local notification.
- localNotification = [[UILocalNotification alloc] init];
- localNotification.alertBody = @"This is notification demo";
- localNotification.alertAction = @"See Me";
- localNotification.fireDate = fireDate;
- localNotification.soundName = UILocalNotificationDefaultSoundName;
- localNotification.applicationIconBadgeNumber++;
- [[UIApplication sharedApplication] scheduleLocalNotification:localNotification];
- [scheduleTextField resignFirstResponder];
Advertisement
Add Comment
Please, Sign In to add comment