Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6538591
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T10:45:13+00:00 2026-05-25T10:45:13+00:00

I have created a date picker programatically in my application . when i select

  • 0

I have created a date picker programatically in my application . when i select any time from my datepicker and click on the add button that date gets added to the cell.detailtext label of my previous controller and as well as that date gets added to the notificationfire date to which the notification should get fired.But i am getting a problem in firing the notification.When i set the date it displays the notification as soon as i click the add button .This is my code to get the date from picker.

This is my controller class in which i created my picker.

- (void)viewDidLoad {
   time = [[NSString alloc] init]; 
   CGRect pickerFrame = CGRectMake(0,40,0,0); 
            
   datePicker = [[UIDatePicker alloc] initWithFrame:pickerFrame]; 
   datePicker.datePickerMode = UIDatePickerModeTime; 
   datePicker.date = [NSDate date];
   [datePicker addTarget:self action:@selector(convertDueDateFormat) forControlEvents:UIControlEventValueChanged]; 
   [self.view addSubview:datePicker]; 
   [datePicker release];
}

-(NSString *)convertDueDateFormat{
   NSDate *pickerDate = self.datePicker.date;
        
   NSDateFormatter *dateFormatter = [[NSDateFormatter alloc]init];
   [dateFormatter setDateFormat:@"hh:mm"];
   NSString *dateString = [dateFormatter stringFromDate:pickerDate];
   NSLog(@"this is check date:%@",dateString);
   //here dateString is a string variable which stores the value of the picker.
   [dateFormatter setTimeZone:[NSTimeZone timeZoneWithAbbreviation:@"GMT"]];
            
   dateFromString = [dateFormatter dateFromString:dateString];
   NSLog(@"Now complete date: %@",dateFromString);
   [dateFormatter release];
            
   //dateFromString is an nsdate variable where i storing the nsdate 
   //by converting the string dateString into date
        
   //dateFromString variable time and dateString variable time does not matches.
                
   return dateString;
}
    

Then i am calling my notification method in my other controller where i have my save button

-(IBAction)save{
  [self setNotification:timepicker.dateFromString message:@"message"];
}
    

timepicker is object of the class where datepicker is created.

How to make my datepicker selected time match with the current time so that the notification can be set at proper time.

Please help me in solving this problem.Thanks

EDIT:

I have added the code for the notification to receive notification in the appdelegate

-(void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification{ 
        
    UIAlertView *alert=[[UIAlertView alloc]initWithTitle:@"Alarm" message:notification.alertBody delegate:self cancelButtonTitle:nil otherButtonTitles:@"SnooZe",@"STOP",nil]; 
    [alert show]; 
    [alert release]; 
    [[UIApplication sharedApplication]cancelLocalNotification:notification]; 
}

to the set the notification this is the code

-(void)setNotification :(NSDate *)dat message:(NSString *)str{ 
    UILocalNotification *local=[[UILocalNotification alloc]init]; 
    [local setAlertBody:str]; 
    [local setFireDate:dat]; 
    [local setSoundName:UILocalNotificationDefaultSoundName]; 
        
    [[UIApplication sharedApplication] scheduleLocalNotification:local]; 
    [local release]; 
}

this method is called in the save button action click

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T10:45:14+00:00Added an answer on May 25, 2026 at 10:45 am

    If you want to change when the selector gets fired, then change the event for the target on the picker.

    If the date is not matching with the current date, then change the formatting of the date to make it match.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created a few small flash widgets that stream .mp3 audio from an
I have this script: select name,create_date,modify_date from sys.procedures order by modify_date desc I can
I have a String representation of a date that I need to create a
I have created a PHP-script to update a web server that is live inside
I have created a UserControl that has a ListView in it. The ListView is
I have created a procedure in dynamic SQL which has a select statement and
Have created a c++ implementation of the Hough transform for detecting lines in images.
I have created a template for Visual Studio 2008 and it currently shows up
I have created a custom dialog for Visual Studio Setup Project using the steps
I have created a C# class file by using a XSD-file as an input.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.