Posted By

saturngod on 10/01/10


Tagged

eventicalcalenderevent


Versions (?)

Who likes this?

3 people have marked this snippet as a favorite

bobbym245
Tintenklecks
cnathan


Save Event in Calendar


 / Published in: Objective C
 

  1. #import "EventTestViewController.h"
  2. #import <EventKit/EventKit.h>
  3.  
  4. @implementation EventTestViewController
  5.  
  6. - (void)viewDidLoad {
  7. [super viewDidLoad];
  8.  
  9. EKEventStore *eventStore = [[EKEventStore alloc] init];
  10.  
  11. EKEvent *event = [EKEvent eventWithEventStore:eventStore];
  12. event.title = @"EVENT TITLE";
  13.  
  14. event.startDate = [[NSDate alloc] init];
  15. event.endDate = [[NSDate alloc] initWithTimeInterval:600 sinceDate:event.startDate];
  16.  
  17. [event setCalendar:[eventStore defaultCalendarForNewEvents]];
  18. NSError *err;
  19. [eventStore saveEvent:event span:EKSpanThisEvent error:&err];
  20. }
  21.  
  22.  
  23.  
  24. - (void)didReceiveMemoryWarning {
  25. // Releases the view if it doesn't have a superview.
  26. [super didReceiveMemoryWarning];
  27.  
  28. // Release any cached data, images, etc that aren't in use.
  29. }
  30.  
  31. - (void)viewDidUnload {
  32. // Release any retained subviews of the main view.
  33. // e.g. self.myOutlet = nil;
  34. }
  35.  
  36.  
  37. - (void)dealloc {
  38. [super dealloc];
  39. }
  40.  
  41. @end

Report this snippet  

You need to login to post a comment.