无法从 ekstore 查询日历中的提醒



我正在尝试从日历中获取提醒列表,但不断收到错误。我可以对日历事件做类似的事情,但是当我尝试修改它以提醒时,我遇到了问题。
此代码在与 EKEntityMaskReminder 有关的第一行失败

   _store = [[EKEventStore alloc] initWithAccessToEntityTypes:EKEntityMaskReminder];
        EKCalendar *calendar = [_store calendarWithIdentifier:[self.detailItem valueForKey:@"cal_id"]];
    NSArray *calendarArray = [NSArray arrayWithObject:calendar];
    NSPredicate *predicate = [_store predicateForRemindersInCalendars:calendarArray];
    _eventsList = [_store fetchRemindersMatchingPredicate:predicate completion:nil];

错误消息是:

-[EKEventStore initWithAccessToEntityTypes:]:发送到实例0x157660的无法识别的选择器

如果我这样更改商店:

_store = [[EKEventStore alloc] init];

然后它失败并显示:

'-[EKEventStore predicateForRemindersInCalendars:]: unrecognized selector sent to instance 0x165c20'

如果我将商店设置为:

_store = [[EKEventStore alloc] init];

它显示在"提醒事项"应用中。

有谁知道为什么我不能查询这些提醒?

您收到错误的两个选择器都从 iOS 6 开始可用。 如果您尝试针对测试版操作系统/库以外的其他内容运行程序,它将失败。

(非常奇怪的是,iOS 5.1 文档中建议使用 initWithAccessToEntityTypes,尽管没有方法说明。

最新更新