我知道 EKEventStore 类具有返回事件存储日历对象数组的@property NSArray *calendars,但是当我只知道日历的标题时,我不知道如何访问该数组中的特定日历。我可以在网上找到的唯一示例是访问 defaultCalendarForNewEvents 的程序,但我想要的日历不是默认日历。我也不知道日历的唯一标识符,我只知道标题。我尝试使用 valueForKey 方法访问名为 BART 的日历,但我所做的绝对是错误的,有人可以帮忙吗?这是我尝试过的:
@interface BARTClass : NSObject {
EKEventStore *eventStore;
EKCalendar *bart
NSArray *calendars;
}
@property (nonatomic, 保留) EKEventStore *eventStore;
@property (nonatomic, 保留) NSArray *calendars;
@property(非原子,保留)EKCalendar *bart;
-(EKCalendar)getBartCalendar;
@结尾
...
@执行
@synthesize 日历、bart、eventStore;
-(EKCalendar)getBartCalendar {
[self setEventStore: [[EKEventStore alloc] init]];
[self setCalendars = [eventStore calendars]];
NSArray *titles = [calendars valueForKey:@"title"];
[self setBart:[titles valueForKey:@"BART"]];
...