0
我試圖按照this tutorial的EKEvent,但我在if (err = noErr) {
當試圖保存
今年年初收到錯誤失敗是我的代碼:
#import "CalendarViewController.h"
#import <EventKit/EventKit.h>
@interface CalendarViewController()
@end
@implementation CalendarViewController
-(IBAction) createEvent {
EKEventStore *eventStore = [[EKEventStore alloc ] init];
EKEvent *event = [EKEvent eventWithEventStore:eventStore];
NSDate *startDate = [[NSDate alloc] init];
NSDate *endDate = [[NSDate alloc] init];
event.title = @"Title for new event";
event.startDate = startDate;
event.endDate = endDate;
event.allDay = YES;
[event setCalendar: [eventStore defaultCalendarForNewEvents]];
NSError *err;
[eventStore saveEvent:event span:EKSpanThisEvent error:&err];
if (err == noErr) {
UIAlertView *alert = [[UIAlertView alloc]
initWithTitle:@"Event Created"
message:@"How about that?"
delegate:nil
cancelButtonTitle:@"Okay"
otherButtonTitles:nil];
[alert show];
[alert release];
}
[startDate release];
[endDate release];
[eventStore release];
}
我是初學者,這是我的HSC的一部分,但我沒有得到它的正常工作。我真的很感激任何幫助。