[英]Array of Calendars
我為我的應用程序使用的EKCalendars創建了NSMutableArray。 在第一次啟動時,我從EventStore導入所有日歷,但不包括Birthdays日歷和默認Calendar,僅保留用戶創建的日歷。 但是,問題在於是否只有生日日歷和默認日歷。 這是我到目前為止所擁有的...
for (int i = 0; i < theEventStore.calendars.count; i++)
{
EKCalendar *c = [theEventStore.calendars objectAtIndex:i];
if (c.type != EKCalendarTypeBirthday && c.type != EKCalendarTypeSubscription)
{
if (c.type == EKCalendarTypeLocal && [c.title isEqualToString:@"Calendar"])
{
NSLog(@"Removed Calendar: %@", c);
}
else
{
[self.calendarLst addObject:c];
NSLog(@"Added Calendar: %@", c);
}
}
}
我有點難過。 任何幫助,將不勝感激。
我已經在原始for循環之后添加了它。 這樣可以確保數組中有內容。
int count = self.calendarLst.count;
NSLog(@"Count: %i",count);
if (count == 0)
{
for (int i = 0; i < theEventStore.calendars.count; i++)
{
EKCalendar *c = [theEventStore.calendars objectAtIndex:i];
if (c.type == EKCalendarTypeLocal && [c.title isEqualToString:@"Calendar"])
{
[self.calendarLst addObject:c];
NSLog(@"Added Calendar: %@", c);
}
}
}
}
問題不在於循環,而是空數組。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.