2011-07-11 7 views
1

私はカレンダーのイベントを検索するには、次の述語を使用しようとしましたが、私はその理由は、以下の 例外「NSInvalidArgumentException」を取得しています:私はEventKitに続いNSPredicateを作成してカレンダーのイベントを検索するにはどうすればよいですか?

 

//[_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]; 

答えて

0

「述語がEKCalendarStoreメソッドを使用して作成されていませんでした」プログラミングガイドと解決策を得た。ここで

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

スウィフト4.0実装です:

import EventKit 

let eventStore = EKEventStore() 
let datePredicate = eventStore.predicateForEvents(withStart: begin, 
    end: end, 
    calendars: eventStore.calendars(for: .event)) 
let events = eventStore.events(matching: datePredicate) 
関連する問題