iphone - 如何创建 NSPredicate 来搜索日历中的事件?

标签 iphone 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];

最佳答案

我遵循了 EventKit 编程指南并得到了解决方案。

   NSPredicate *prediction=[eventStore predicateForEventsWithStartDate:statedate endDate:enddate calendars:[eventStore calendars]];
   NSArray*events=[eventStore eventsMatchingPredicate:prediction];

关于iphone - 如何创建 NSPredicate 来搜索日历中的事件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6649650/

相关文章:

iphone - 当模型改变时删除存储在 CoreData 中的所有数据

ios - Coredata 不支持谓词但仅支持非家庭计算

cocoa - 使用 @avg 集合运算符格式化 NSPredicate 的字符串

ios - 通用功能在同一环境中表现不同

iphone - NSFetchResultsController 委托(delegate)没有被调用

ios - 如何使用谓词从一个 NSArray 中选择包含在另一个 NSArray 中的对象

ios - Coredata fetchrequest 谓词未显示正确的内容

ios - NSPredicate 格式说明符问题

iPhone 没有崩溃,仪器没有泄漏,应用程序可以上传了吗?

iPhone线程加速应用程序的启动