following iOS6 eventKit and the new privacy settings I am using the following code - which works perfectly fine on iOS6 devices.
Still, I would like the same code to work also for devices with iOS 5.x and I wish not to write a the "same code" twice - Seems wrong.
Can anyone assist in an elegant solution ?
EKEventStore *eventStore = [[EKEventStore alloc] init];
[eventStore requestAccessToEntityType:EKEntityTypeEvent completion:^(BOOL granted, NSError *error) {
// some code
}];
If you show the event in a modalviewcontroller with a EKEventEditViewController, iOS automatically show you a view saying what to do if the permission is denied. So, I do this:
In viewDidLoad:
In the method used to add the event:
I'm using this:
I think that should reduce code duplication.
I have an EventUtil.m file with
And in the view controller that I want to access the calendar I import the EventUtil.h file and call this function:
displayModifyCalendarAlertView is the function I want to call if the calendar permission is given (either iOS6 or iOS < 6).