I've written this code below just to get it to compile but this will not work, because I need to have a deployment target of 10.8.
what is going on is I need access to EKEventStore , so when someone downloads this app, it runs fine in 10.8, but someone downloading in 10.9 would get errors, because the app doesn't have Privacy permission to the calendar. Since it is being compiled for 10.8, it has no access to the method requestAccessToEntityType:EKEntityTypeEvent..
how would one go about doing this?
on a related note, how do you compile code for 10.9, other code for 10.8, and call those different parts depending on the environment it is in? remembering this is for the Mac App Store, and if that is the way to go, be illustrative, as if you are talking to someone who has no idea how to begin to do this, because I don't.. thanks.
//------------------check authorization of calendars--------------
#if (__MAC_OS_X_VERSION_MIN_REQUIRED >= 1090) || (__IPHONE_OS_VERSION_MIN_REQUIRED)
if(!eventStore) eventStore = [[EKEventStore alloc] init];
[eventStore requestAccessToEntityType:EKEntityTypeEvent completion:^(BOOL granted, NSError *error) //.............put this back in...
{
if (granted)
{
NSLog(@"granted permission to eventstore!");
authorizedEventStore = YES;
authorizedCalendar();
}
else
{
NSLog(@"Not granted");
authorizedEventStore = NO;
notAuthorized();
}
}];
#else
NSLog(@"not able to request");
if(!eventStore) eventStore = [[EKEventStore alloc] initWithAccessToEntityTypes:EKEntityMaskEvent];
authorizedEventStore = YES;
authorizedCalendar();
#endif
//------------------end check authorization of calendars--------------
To have an App that runs on several OS versions:
see also: How to conditionally use a new Cocoa API and How do I include calls to methods only present in one operating system version when compiling for multiple versions?