參閱事件套件編程指南位於:
http://developer.apple.com/library/ios/#documentation/DataManagement/Conceptual/EventKitProgGuide/Introduction/Introduction.html
下面是蘋果的示例代碼:https://developer.apple.com/library/ios/samplecode/SimpleEKDemo/Introduction/Intro.html
的用於添加事件的代碼使用EKEventEditViewController:
// Create an instance of EKEventEditViewController
EKEventEditViewController *addController = [[EKEventEditViewController alloc] init];
// Set addController's event store to the current event store
addController.eventStore = self.eventStore;
addController.editViewDelegate = self;
[self presentViewController:addController animated:YES completion:nil];
加入後,您可以獲取使用代碼來自教程,檢索事件與謂詞(在這種情況下日期)事件:
NSDate *startDate = [NSDate date];
//Create the end date components
NSDateComponents *tomorrowDateComponents = [[NSDateComponents alloc] init];
tomorrowDateComponents.day = 1;
NSDate *endDate = [[NSCalendar currentCalendar] dateByAddingComponents:tomorrowDateComponents
toDate:startDate
options:0];
// We will only search the default calendar for our events
NSArray *calendarArray = [NSArray arrayWithObject:self.defaultCalendar];
// Create the predicate
NSPredicate *predicate = [self.eventStore predicateForEventsWithStartDate:startDate
endDate:endDate
calendars:calendarArray];
// Fetch all events that match the predicate
NSMutableArray *events = [NSMutableArray arrayWithArray:[self.eventStore eventsMatchingPredicate:predicate]];
return events;
讓我檢查一下,它會爲我服務以及將爲其接受我的個人日曆並使用JSON將數據發送到Web平臺? 我不使用本地日曆 謝謝 –
非常感謝你我正在看教程現在, –
我看了視頻,它很有用,但我不使用默認日曆,所以我不知道是否需要其他類型的東西,因爲我使用JSON在網絡平臺中添加事件 –