创建ekios目标-C

创建ekios目标-C,ios,objective-c,calendar,eventkit,ekeventkit,Ios,Objective C,Calendar,Eventkit,Ekeventkit,我使用EventKit创建日历。 我尝试使用这种方法创建它。当我在模拟器中测试它时,日历创建(屏幕截图)并显示在默认日历中,但当我在设备上执行相同操作时,它不工作,没有错误,都一样,但没有结果 `你说“不起作用”是什么意思?请解释应该发生什么以及正在发生什么。你有什么错误吗?你做了什么来解决这个问题?我更正了我的问题。 -(void)createCalendar{ EKEventStore *eventStore = [[EKEventStore alloc] init]; EK

我使用EventKit创建日历。 我尝试使用这种方法创建它。当我在模拟器中测试它时,日历创建(屏幕截图)并显示在默认日历中,但当我在设备上执行相同操作时,它不工作,没有错误,都一样,但没有结果


`

你说“不起作用”是什么意思?请解释应该发生什么以及正在发生什么。你有什么错误吗?你做了什么来解决这个问题?我更正了我的问题。
-(void)createCalendar{
    EKEventStore *eventStore = [[EKEventStore alloc] init];
    EKCalendar *calendar = [EKCalendar    calendarForEntityType:EKEntityTypeEvent eventStore:eventStore];
calendar.title = @"my calendarik";

// Iterate over all sources in the event store and look for the local source
EKSource *theSource = nil;
for (EKSource *source in eventStore.sources) {
    if (source.sourceType == EKSourceTypeLocal) {
        theSource = source;
        break;
    }
}
NSString    *iden = calendar.calendarIdentifier;

if (theSource) {
    calendar.source = theSource;
} else {
    NSLog(@"Error: Local source not available");
    return;
}

NSError *error = nil;
BOOL result = [eventStore saveCalendar:calendar commit:YES error:&error];
if (result) {
    NSLog(@"Saved calendar to event store.");

} else {
    NSLog(@"Error saving calendar: %@.", error);
}
   EKCalendar* calendar_;


    NSArray *allCalendars = [eventStore calendarsForEntityType:EKEntityTypeEvent];
    for (EKCalendar *cal in allCalendars) {
    if ([cal.calendarIdentifier isEqualToString:iden]) {
                        calendar_ = cal;
                           break;

            }

else {
        calendar_ = [eventStore calendarWithIdentifier:iden];
    }
   }