2013-01-21 65 views
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; 
    } 
} 

1號線和2號線得到一個錯誤:「日曆棄用:在iOS 6中第一棄用」
如何解決呢?日曆棄用

回答

5

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

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


NSArray *cals = [eventStore calendarsForEntityType: EKEntityTypeEvent]; 

並在line2中使用陣列cals

檢查文檔here