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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T16:51:10+00:00 2026-05-26T16:51:10+00:00

I am a beginner in Xcode and searched the following codes for adding an

  • 0

I am a beginner in Xcode and searched the following codes for adding an event into ical inside my app. But the example only show me how to set the start day and end day using [[NSDate alloc] init];

What code i can get in order to set the date as I want e.g. 20-12-2012?

Thanks for your time.

EKEventStore *eventDB = [[EKEventStore alloc] init];

EKEvent *myEvent  = [EKEvent eventWithEventStore:eventDB];

myEvent.title     = @"New Event";
myEvent.startDate = [[NSDate alloc]init ];

myEvent.endDate   = [[NSDate alloc]init ];
myEvent.allDay = YES;

[myEvent setCalendar:[eventDB defaultCalendarForNewEvents]];

NSError *err;

[eventDB saveEvent:myEvent span:EKSpanThisEvent error:&err]; 


    UIAlertView *alert = [[UIAlertView alloc]
                          initWithTitle:@"Event Created"
                          message:@"Yay!?"
                          delegate:nil
                          cancelButtonTitle:@"Okay"
                          otherButtonTitles:nil];
    [alert show];
  • 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-26T16:51:11+00:00Added an answer on May 26, 2026 at 4:51 pm

    As you’ve discovered, setting a NSDate object to non-trivial dates is entirely non-trivial.

    There’s a couple ways to do this.

    1)

    Check out the documentation for [NSDateFormatter dateFromString:].

    2)

    Here’s another way to set December 20th, 2012.

    NSCalendar * gregorian = [NSCalendar currentCalendar];
    NSDate *currentDate = [NSDate dateWithTimeIntervalSinceReferenceDate: 0];
    NSDateComponents *comps = [[NSDateComponents alloc] init];
    [comps setYear: 11]; // 11 years past the reference date of 1-January-2001
    [comps setMonth: 11]; // 11 months past January
    [comps setDay:19]; // 19 days past the first day of January
    NSDate *eventDate = [gregorian dateByAddingComponents:comps toDate:currentDate  options:0];
    
    NSLog( @"event date is %@", [eventDate description] );
    [comps release]; // NSDateComponents was explicitly alloc'd & init'd
    
    myEvent.startDate = eventDate;
    mtEvent.endDate = eventDate;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm a complete beginner to Apple's Xcode, but I have followed the Xcode documentation
Beginner help needed :) I am doign an example form a php book which
I'm not a beginner at C# but I really need to increase my understanding,
Once again a very beginner-ish question, but here I go: I would like to
I am a beginner in xcode, I want to know how can I implement
i am a beginner for iphone and xcode pls anybody give me code to
I am using MacOSX 10.6, and the Xcode simulator is 4.2, but after trying
Beginner in python, but been programming for about 5 years now. I suspect I
Beginner here See - http://www.w3schools.com/js/tryit.asp?filename=try_dom_tablerow_cells In this example, when change content is pressed, new
Level: Beginner In the following code my 'samePoint' function returns False where i am

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.