日历已弃用

4
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;
     }
}

第一行和第二行出现错误:"calendars deprecated : first deprecated in IOS 6"
如何解决?

1个回答

5
相反,您必须使用以下方法。
- (NSArray *)calendarsForEntityType:(EKEntityType)entityType;


NSArray *cals = [eventStore calendarsForEntityType: EKEntityTypeEvent];

在第二行中使用数组 cals

查看文档此处


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接