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 7090555
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T08:04:09+00:00 2026-05-28T08:04:09+00:00

I was wondering how I would edit the dateComps setDay: to go off 3

  • 0

I was wondering how I would edit the dateComps setDay: to go off 3 days before the date set in the picker. I typed in -3, but that doesn’t seem to do the trick.
Any help is much appreciated! Here is my code:

- (IBAction)scheduleNotifButton:(id)sender {
    NSCalendar *calendar = [NSCalendar autoupdatingCurrentCalendar];

    NSDate *pickerDate = [self.datePicker date];

    NSDateComponents *dateComponents = [calendar components:( NSYearCalendarUnit | NSMonthCalendarUnit |  NSDayCalendarUnit )
                                                   fromDate:pickerDate];
    NSDateComponents *timeComponents = [calendar components:( NSHourCalendarUnit | NSMinuteCalendarUnit | NSSecondCalendarUnit )
                                                   fromDate:pickerDate];

    NSDateComponents *dateComps = [[NSDateComponents alloc] init];
    [dateComps setDay:[dateComponents day]];
    [dateComps setMonth:[dateComponents month]];
    [dateComps setYear:[dateComponents year]];
    [dateComps setHour:13];
    [dateComps setMinute:30];
    [dateComps setSecond:[timeComponents second]];
    NSDate *itemDate = [calendar dateFromComponents:dateComps];

    UILocalNotification *localNotif = [[UILocalNotification alloc] init];
    if (localNotif == nil)
        return;
    localNotif.fireDate = itemDate;
    localNotif.timeZone = [NSTimeZone defaultTimeZone];

    localNotif.alertBody = @"Event is in 3 days!";
    localNotif.alertAction = nil;

    localNotif.soundName = UILocalNotificationDefaultSoundName;
    localNotif.applicationIconBadgeNumber = 0;

    [[UIApplication sharedApplication] scheduleLocalNotification:localNotif];

}
  • 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-28T08:04:10+00:00Added an answer on May 28, 2026 at 8:04 am

    When you say you have typed -3, do you mean you used this line?

    [dateComps setDay:[dateComponents day] - 3];
    

    This should in fact work.

    Also, you can tell the system to fire any next year by just settings the current year to the date components. You can find the current year just the way you found the date components for pickerDate.

    After that, you can set the repeatInterval of the local notification to NSYearCalendarUnit, that way it will fire each year.

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

Sidebar

Related Questions

I have run a few using batch jobs, but, I am wondering what would
I have to create a method find that would use a local Set to
I was wondering what would be the most simple but secure method for the
I was wondering how you would write a method in Scala that takes a
I was wondering would I still need to use a basic game loop for
I provide a web service to my organisation. i was wondering would anyone recommeding
I was wondering what would be the best strategy to implement a badges system
I'm wondering what would be the best prectice regarding mainataining connections to the database
i was wondering what would be the best way to code a browser plugin
I was just wondering which would be cheaper, using a try catch block for

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.