日历已弃用

时间:2013-01-21 12:15:38

标签: ios6 calendar

if ([eventStore.calendars count] == 0)   
    { 
        NSLog(@"No calendars are found.");
        return NO;
    }
 EKCalendar *targetCalendar = nil;
 /* Try to find the calendar that the user asked for */
 for (EKCalendar *thisCalendar in eventStore.calendars){ line2
     if ([thisCalendar.title isEqualToString:paramCalendarTitle] &&
         thisCalendar.type == paramCalendarType){
        targetCalendar = thisCalendar;
        break;
     }
}

第1行和第2行出错:“日历已弃用:首先在IOS 6中弃用”
如何解决?

1 个答案:

答案 0 :(得分:5)

相反,您必须使用以下方法。

- (NSArray *)calendarsForEntityType:(EKEntityType)entityType;


NSArray *cals = [eventStore calendarsForEntityType: EKEntityTypeEvent];

并在第2行使用数组cals

查看文档here