我尝试使用以下谓词来搜索日历中的事件,但我得到以下信息 异常 '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/