//
// ViewController.m
// EKEventStore
//
// Created by 吴小海 on 12-12-12.
// Copyright (c) 2012年 吴小海. All rights reserved.
//
#import "ViewController.h"
#import <EventKit/EventKit.h>
#import <EventKitUI/EventKitUI.h>
@interface ViewController ()
@end
@implementation ViewController
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (IBAction)testKEEvent:(id)sender {
EKEventStore *eventDB = [[EKEventStore alloc] init];
[eventDB requestAccessToEntityType:EKEntityTypeEvent completion:^(BOOL granted,
NSError *error) {
// handle access here
EKEvent *myEvent = [EKEvent eventWithEventStore:eventDB];
myEvent.title = @"今天下午的任务";
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];
}];
}
@end