Created
February 13, 2015 18:22
-
-
Save Paulo-Branco/eb0d876d7af446fc75bb to your computer and use it in GitHub Desktop.
[Debug] - Add a current calendar event
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
NSDateComponents *dateComponents5 = [[NSCalendar currentCalendar] components:NSDayCalendarUnit|NSMonthCalendarUnit|NSYearCalendarUnit|NSHourCalendarUnit fromDate:[NSDate date]]; | |
[dateComponents5 setHour:dateComponents5.hour - 1]; /* Started one hour ago */ | |
Calendar *newItem5 = [Calendar newEntityWithError:nil]; | |
[newItem5 setClassStart:[[NSCalendar currentCalendar] dateFromComponents:dateComponents5]]; | |
[newItem5 setClassEnd:[[[NSCalendar currentCalendar] dateFromComponents:dateComponents5] dateByAddingTimeInterval:3600*3]]; /* Lasts for 4 hours */ | |
[newItem5 setEventType:@"CLASS"]; | |
[newItem5 setEventName:[NSString stringWithFormat:@"%@ - Theoretical", exampleCourse4.courseName]]; | |
[newItem5 addCoursesObject:exampleCourse4]; | |
[Calendar commit]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment