事件添加iOS 6.1中的所有日历?

时间:2013-04-26 07:28:17

标签: iphone events ios6 calendar

我试图从我的iPhone(iOS 6.1)获取日历标题,但内部没有任何内容。 如何从iOS 6.1获取日历标题?请帮帮我。

感谢Adnvance

我试过了:

EKEventStore *store = [[EKEventStore alloc]init];
EKEvent *event = [EKEvent eventWithEventStore:store];
NSArray *list = [[NSArray alloc]init];
list = [[store calendarsForEntityType:EKEntityTypeEvent] copy];
// Calendars deprecate in iOs 6.1
// Retain deprecate, so use "copy"


NSLog(@"list:  %d",[list count]);

for(EKCalendar *calendar in list)
{
    NSLog(@"list:  %@",calendar.title);
}

1 个答案:

答案 0 :(得分:2)

希望这会有所帮助......

EKEventStore *store = [[EKEventStore alloc] init];
[store requestAccessToEntityType:EKEntityTypeEvent completion:^(BOOL granted, NSError *error) {
    }];
NSArray *arrCalenders = [store calendars];//below iOS 6.o
NSLog(@"%@", arrCalenders);
NSArray *arrayCalndars = [store calendarsForEntityType:EKEntityTypeEvent]; // In ios 6.o
NSLog(@"%@", arrayCalndars);

这会显示当前的日历列表......