Dav*_*ong 21
搜索文档会显示EKEventStore
具有calendars
属性的类.
我的猜测是你做的事情如下:
EKEventStore * eventStore = [[EKEventStore alloc] init];
NSArray * calendars = [eventStore calendars];
Run Code Online (Sandbox Code Playgroud)
编辑:从iOS 6开始,您需要指定是否要检索提醒日历或日历事件日历:
EKEventStore * eventStore = [[EKEventStore alloc] init];
EKEntityType type = // EKEntityTypeReminder or EKEntityTypeEvent
NSArray * calendars = [eventStore calendarsForEntityType:type];
Run Code Online (Sandbox Code Playgroud)
我用来获取日历名称和类型的可用NSDictionary的代码是这样的:
//*** Returns a dictionary containing device's calendars by type (only writable calendars)
- (NSDictionary *)listCalendars {
EKEventStore *eventDB = [[EKEventStore alloc] init];
NSArray * calendars = [eventDB calendars];
NSMutableDictionary *dict = [[NSMutableDictionary alloc] init];
NSString * typeString = @"";
for (EKCalendar *thisCalendar in calendars) {
EKCalendarType type = thisCalendar.type;
if (type == EKCalendarTypeLocal) {
typeString = @"local";
}
if (type == EKCalendarTypeCalDAV) {
typeString = @"calDAV";
}
if (type == EKCalendarTypeExchange) {
typeString = @"exchange";
}
if (type == EKCalendarTypeSubscription) {
typeString = @"subscription";
}
if (type == EKCalendarTypeBirthday) {
typeString = @"birthday";
}
if (thisCalendar.allowsContentModifications) {
NSLog(@"The title is:%@", thisCalendar.title);
[dict setObject: typeString forKey: thisCalendar.title];
}
}
return dict;
}
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
6708 次 |
最近记录: |