如何创建 NSPredicate 来搜索日历中的事件?
我尝试使用以下谓词来搜索日历中的事件,但我得到以下结果 异常“NSInvalidArgumentException”,原因:“谓词不是使用 EKCalendarStore 方法创建的”
//[_sender objectAtIndex:0] is Name of the event and [_sender objectAtIndex:1] is location of the event NSPredicate *prediction=[NSPredicate predicateWithFormat:@"(SELF contains[cd] %@)", [NSString stringWithFormat: @"%@%@",[_sender objectAtIndex:0],[_sender objectAtIndex:1]]]; NSArray*events=[eventStore eventsMatchingPredicate:prediction];
I tried to use following predicate to search for events in the Calendar but i'm getting the following
exception 'NSInvalidArgumentException', reason: 'predicate was not created with EKCalendarStore methods'
//[_sender objectAtIndex:0] is Name of the event and [_sender objectAtIndex:1] is location of the event NSPredicate *prediction=[NSPredicate predicateWithFormat:@"(SELF contains[cd] %@)", [NSString stringWithFormat: @"%@%@",[_sender objectAtIndex:0],[_sender objectAtIndex:1]]]; NSArray*events=[eventStore eventsMatchingPredicate:prediction];
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我按照 EventKit 编程指南并得到了解决方案。
I followed the EventKit Programming Guide and got the solution.
这是一个 Swift 4.0 实现:
Here is a Swift 4.0 implementation: