Note that there are some explanatory texts on larger screens.

plurals
  1. POiPhone: Getting date from date picker
    primarykey
    data
    text
    <p>I wrote an app that allows users to enter in a date on a date picker, and the app will alert the user 36 hours before that date arrives. My issue is in the <code>dateFromString:</code>. I'm not sure what to put in there. Here is the code:</p> <pre><code>- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { UILocalNotification *localNotif = [[UILocalNotification alloc] init]; NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; [dateFormatter setDateFormat:@"mm'/'dd'/'yyyy"]; NSDate *eventDate=[dateFormatter dateFromString: ]; localNotif.fireDate = [eventDate dateByAddingTimeInterval:-13*60*60]; localNotif.timeZone = [NSTimeZone defaultTimeZone]; localNotif.alertBody = @"Event tommorow!"; localNotif.alertAction = nil; localNotif.soundName = UILocalNotificationDefaultSoundName; localNotif.applicationIconBadgeNumber = 0; [[UIApplication sharedApplication]presentLocalNotificationNow:localNotif]; return YES; </code></pre> <p>}</p> <p>Any help is much appreciated, thank you!</p> <p>Edit: Here is some additional code that I'm using to save the date they entered on the date picker if that helps:</p> <pre><code>- (void)viewDidLoad { NSDate *storedDate = [[NSUserDefaults standardUserDefaults] objectForKey:@"DatePickerViewController.selectedDate"]; [self.datePicker setDate:storedDate animated:NO]; } </code></pre> <p>And this is the method that saves the data:</p> <pre><code>- (IBAction)dateChanged:(id)sender { NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; NSDate *selectedDate = [self.datePicker date]; [defaults setObject:selectedDate forKey:@"DatePickerViewController.selectedDate"];} </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload