objc2_event_kit/generated/
EKEventStore.rs

1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::ffi::*;
4use core::ptr::NonNull;
5use objc2::__framework_prelude::*;
6use objc2_foundation::*;
7
8use crate::*;
9
10/// Values for controlling what occurrences to affect in a recurring event.
11///
12/// This enumerated type is used to indicate the scope of a change being made to a repeating event. EKSpanThisEvent
13/// indicates the changes should apply only to this event, EKSpanFutureEvents indicates the changes should apply to
14/// this event and all future events in the pattern.
15///
16/// See also [Apple's documentation](https://developer.apple.com/documentation/eventkit/ekspan?language=objc)
17// NS_ENUM
18#[repr(transparent)]
19#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
20pub struct EKSpan(pub NSInteger);
21impl EKSpan {
22    #[doc(alias = "EKSpanThisEvent")]
23    pub const ThisEvent: Self = Self(0);
24    #[doc(alias = "EKSpanFutureEvents")]
25    pub const FutureEvents: Self = Self(1);
26}
27
28unsafe impl Encode for EKSpan {
29    const ENCODING: Encoding = NSInteger::ENCODING;
30}
31
32unsafe impl RefEncode for EKSpan {
33    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
34}
35
36/// [Apple's documentation](https://developer.apple.com/documentation/eventkit/ekeventsearchcallback?language=objc)
37#[cfg(all(
38    feature = "EKCalendarItem",
39    feature = "EKEvent",
40    feature = "EKObject",
41    feature = "block2"
42))]
43pub type EKEventSearchCallback = *mut block2::DynBlock<dyn Fn(NonNull<EKEvent>, NonNull<Bool>)>;
44
45/// [Apple's documentation](https://developer.apple.com/documentation/eventkit/ekeventstorerequestaccesscompletionhandler?language=objc)
46#[cfg(feature = "block2")]
47pub type EKEventStoreRequestAccessCompletionHandler =
48    *mut block2::DynBlock<dyn Fn(Bool, *mut NSError)>;
49
50extern_class!(
51    /// The EKEventStore class provides an interface for accessing and manipulating calendar events and reminders.
52    ///
53    /// The EKEventStore class is the main point of contact for accessing Calendar data. You must
54    /// create a EKEventStore object in order to retrieve/add/delete events or reminders from the Calendar database.
55    ///
56    /// Events, Reminders, and Calendar objects retrieved from an event store cannot be used with any other event
57    /// store. It is generally best to hold onto a long-lived instance of an event store, most
58    /// likely as a singleton instance in your application.
59    ///
60    /// See also [Apple's documentation](https://developer.apple.com/documentation/eventkit/ekeventstore?language=objc)
61    #[unsafe(super(NSObject))]
62    #[derive(Debug, PartialEq, Eq, Hash)]
63    pub struct EKEventStore;
64);
65
66extern_conformance!(
67    unsafe impl NSObjectProtocol for EKEventStore {}
68);
69
70impl EKEventStore {
71    extern_methods!(
72        #[cfg(feature = "EKTypes")]
73        /// Returns the authorization status for the given entity type
74        #[unsafe(method(authorizationStatusForEntityType:))]
75        #[unsafe(method_family = none)]
76        pub unsafe fn authorizationStatusForEntityType(
77            entity_type: EKEntityType,
78        ) -> EKAuthorizationStatus;
79
80        #[cfg(feature = "EKTypes")]
81        /// Users are able to grant or deny access to event and reminder data on a per-app basis. To request access to
82        /// event and/or reminder data, instantiate an EKEventStore using this method. This call will not block the
83        /// program while the user is being asked to grant or deny access. Until access has been granted for an entity
84        /// type, this event store will not contain any calendars for that entity type, and any attempt to save entities
85        /// of that entity type will fail. If access is later granted or declined, the event store will broadcast an
86        /// EKEventStoreChangedNotification. You can check the current access status for an entity type
87        /// using +authorizationStatusForEntityType:. The user will only be prompted the first time access is requested; any
88        /// subsequent instantiations of EKEventStore will use the existing permissions.
89        ///
90        /// Parameter `entityTypes`: A bit mask of entity types to which you want access
91        #[deprecated]
92        #[unsafe(method(initWithAccessToEntityTypes:))]
93        #[unsafe(method_family = init)]
94        pub unsafe fn initWithAccessToEntityTypes(
95            this: Allocated<Self>,
96            entity_types: EKEntityMask,
97        ) -> Retained<Self>;
98
99        #[unsafe(method(init))]
100        #[unsafe(method_family = init)]
101        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
102
103        #[cfg(all(feature = "EKObject", feature = "EKSource"))]
104        /// Creates a new event store that only includes items and calendars for a subset of sources.
105        ///
106        /// Parameter `sources`: The sources you want this event store to recognize. This may include delegate sources.
107        #[unsafe(method(initWithSources:))]
108        #[unsafe(method_family = init)]
109        pub unsafe fn initWithSources(
110            this: Allocated<Self>,
111            sources: &NSArray<EKSource>,
112        ) -> Retained<Self>;
113
114        #[cfg(feature = "block2")]
115        /// # Safety
116        ///
117        /// `completion` must be a valid pointer.
118        #[unsafe(method(requestFullAccessToEventsWithCompletion:))]
119        #[unsafe(method_family = none)]
120        pub unsafe fn requestFullAccessToEventsWithCompletion(
121            &self,
122            completion: EKEventStoreRequestAccessCompletionHandler,
123        );
124
125        #[cfg(feature = "block2")]
126        /// # Safety
127        ///
128        /// `completion` must be a valid pointer.
129        #[unsafe(method(requestWriteOnlyAccessToEventsWithCompletion:))]
130        #[unsafe(method_family = none)]
131        pub unsafe fn requestWriteOnlyAccessToEventsWithCompletion(
132            &self,
133            completion: EKEventStoreRequestAccessCompletionHandler,
134        );
135
136        #[cfg(feature = "block2")]
137        /// # Safety
138        ///
139        /// `completion` must be a valid pointer.
140        #[unsafe(method(requestFullAccessToRemindersWithCompletion:))]
141        #[unsafe(method_family = none)]
142        pub unsafe fn requestFullAccessToRemindersWithCompletion(
143            &self,
144            completion: EKEventStoreRequestAccessCompletionHandler,
145        );
146
147        #[cfg(all(feature = "EKTypes", feature = "block2"))]
148        /// # Safety
149        ///
150        /// `completion` must be a valid pointer.
151        #[deprecated = "Use -requestFullAccessToEventsWithCompletion:, -requestWriteOnlyAccessToEventsWithCompletion:, or -requestFullAccessToRemindersWithCompletion:"]
152        #[unsafe(method(requestAccessToEntityType:completion:))]
153        #[unsafe(method_family = none)]
154        pub unsafe fn requestAccessToEntityType_completion(
155            &self,
156            entity_type: EKEntityType,
157            completion: EKEventStoreRequestAccessCompletionHandler,
158        );
159
160        /// Returns a unique identifier string representing this calendar store.
161        #[unsafe(method(eventStoreIdentifier))]
162        #[unsafe(method_family = none)]
163        pub unsafe fn eventStoreIdentifier(&self) -> Retained<NSString>;
164
165        #[cfg(all(feature = "EKObject", feature = "EKSource"))]
166        /// Returns an unordered array of sources for all available delegates.
167        #[unsafe(method(delegateSources))]
168        #[unsafe(method_family = none)]
169        pub unsafe fn delegateSources(&self) -> Retained<NSArray<EKSource>>;
170
171        #[cfg(all(feature = "EKObject", feature = "EKSource"))]
172        /// Returns an unordered array of sources.
173        #[unsafe(method(sources))]
174        #[unsafe(method_family = none)]
175        pub unsafe fn sources(&self) -> Retained<NSArray<EKSource>>;
176
177        #[cfg(all(feature = "EKObject", feature = "EKSource"))]
178        /// Returns a source with a specified identifier.
179        #[unsafe(method(sourceWithIdentifier:))]
180        #[unsafe(method_family = none)]
181        pub unsafe fn sourceWithIdentifier(
182            &self,
183            identifier: &NSString,
184        ) -> Option<Retained<EKSource>>;
185
186        #[cfg(all(feature = "EKCalendar", feature = "EKObject"))]
187        /// While this returns an array, the calendars are unordered. This call is deprecated
188        /// and only returns calendars that support events. If you want reminder calendars
189        /// you should use calendarsForEntityType:
190        #[unsafe(method(calendars))]
191        #[unsafe(method_family = none)]
192        pub unsafe fn calendars(&self) -> Retained<NSArray<EKCalendar>>;
193
194        #[cfg(all(feature = "EKCalendar", feature = "EKObject", feature = "EKTypes"))]
195        /// Returns calendars that support a given entity type (reminders, events)
196        #[unsafe(method(calendarsForEntityType:))]
197        #[unsafe(method_family = none)]
198        pub unsafe fn calendarsForEntityType(
199            &self,
200            entity_type: EKEntityType,
201        ) -> Retained<NSArray<EKCalendar>>;
202
203        #[cfg(all(feature = "EKCalendar", feature = "EKObject"))]
204        /// Returns the calendar that events should be added to by default.
205        ///
206        /// This may be nil if there is no default calendar for new events.
207        #[unsafe(method(defaultCalendarForNewEvents))]
208        #[unsafe(method_family = none)]
209        pub unsafe fn defaultCalendarForNewEvents(&self) -> Option<Retained<EKCalendar>>;
210
211        #[cfg(all(feature = "EKCalendar", feature = "EKObject"))]
212        /// Returns the calendar that reminders should be added to by default.
213        ///
214        /// This may be nil if there is no default calendar for new reminders.
215        #[unsafe(method(defaultCalendarForNewReminders))]
216        #[unsafe(method_family = none)]
217        pub unsafe fn defaultCalendarForNewReminders(&self) -> Option<Retained<EKCalendar>>;
218
219        #[cfg(all(feature = "EKCalendar", feature = "EKObject"))]
220        /// Returns a calendar with a specified identifier.
221        #[unsafe(method(calendarWithIdentifier:))]
222        #[unsafe(method_family = none)]
223        pub unsafe fn calendarWithIdentifier(
224            &self,
225            identifier: &NSString,
226        ) -> Option<Retained<EKCalendar>>;
227
228        #[cfg(all(feature = "EKCalendar", feature = "EKObject"))]
229        /// Saves changes to a calendar, or adds a new calendar to the database.
230        ///
231        /// This method attempts to save the given calendar to the calendar database. It
232        /// returns YES if successful and NO otherwise. Passing a calendar fetched from
233        /// another EKEventStore instance into this function will raise an exception.
234        /// On WatchOS, saving changes is not supported.
235        ///
236        ///
237        /// Parameter `calendar`: The calendar to save.
238        ///
239        /// Parameter `commit`: Pass YES to cause the database to save. You can pass NO to save multiple
240        /// calendars and then call commit: to save them all at once.
241        ///
242        /// Parameter `error`: If an error occurs, this will contain a valid NSError object on exit.
243        #[unsafe(method(saveCalendar:commit:error:_))]
244        #[unsafe(method_family = none)]
245        pub unsafe fn saveCalendar_commit_error(
246            &self,
247            calendar: &EKCalendar,
248            commit: bool,
249        ) -> Result<(), Retained<NSError>>;
250
251        #[cfg(all(feature = "EKCalendar", feature = "EKObject"))]
252        /// Removes a calendar from the database.
253        ///
254        /// This method attempts to delete the given calendar from the calendar database. It
255        /// returns YES if successful and NO otherwise. Passing a calendar fetched from
256        /// another EKEventStore instance into this function will raise an exception.
257        ///
258        /// If the calendar supports multiple entity types (allowedEntityTypes), but the user has
259        /// not granted you access to all those entity types, then we will delete all of the entity types
260        /// for which you have access and remove that entity type from the allowedEntityTypes.
261        /// For example: If a calendar supports both events and reminders, but you only have access to reminders,
262        /// we will delete all the reminders and make the calendar only support events.
263        ///
264        /// If you have access to all of its allowedEntityTypes, then it will delete the calendar and
265        /// all of the events and reminders in the calendar.
266        ///
267        /// On WatchOS, modifying the database is not supported.
268        ///
269        ///
270        /// Parameter `calendar`: The calendar to delete.
271        ///
272        /// Parameter `commit`: Pass YES to cause the database to save. You can pass NO to batch multiple
273        /// changes and then call commit: to save them all at once.
274        ///
275        /// Parameter `error`: If an error occurs, this will contain a valid NSError object on exit.
276        #[unsafe(method(removeCalendar:commit:error:_))]
277        #[unsafe(method_family = none)]
278        pub unsafe fn removeCalendar_commit_error(
279            &self,
280            calendar: &EKCalendar,
281            commit: bool,
282        ) -> Result<(), Retained<NSError>>;
283
284        #[cfg(all(feature = "EKCalendarItem", feature = "EKObject"))]
285        /// Returns either a reminder or the first occurrence of an event.
286        #[unsafe(method(calendarItemWithIdentifier:))]
287        #[unsafe(method_family = none)]
288        pub unsafe fn calendarItemWithIdentifier(
289            &self,
290            identifier: &NSString,
291        ) -> Option<Retained<EKCalendarItem>>;
292
293        #[cfg(all(feature = "EKCalendarItem", feature = "EKObject"))]
294        /// Returns either matching reminders or the first occurrences of any events matching
295        /// the given external identifier.
296        ///
297        /// This method returns a set of EKEvents or EKReminders with the given external identifier.
298        /// Due to reasons discussed in -[EKCalendarItem calendarItemExternalIdentifier], there may be
299        /// more than one matching calendar item.
300        ///
301        ///
302        /// Parameter `externalIdentifier`: The value obtained from EKCalendarItem's
303        /// calendarItemExternalIdentifier property
304        ///
305        /// Returns: An unsorted array of EKCalendarItem instances
306        #[unsafe(method(calendarItemsWithExternalIdentifier:))]
307        #[unsafe(method_family = none)]
308        pub unsafe fn calendarItemsWithExternalIdentifier(
309            &self,
310            external_identifier: &NSString,
311        ) -> Retained<NSArray<EKCalendarItem>>;
312
313        #[cfg(all(feature = "EKCalendarItem", feature = "EKEvent", feature = "EKObject"))]
314        /// Saves changes to an event permanently.
315        ///
316        /// This method attempts to save the event to the calendar database. It returns YES if
317        /// successful and NO otherwise. It's possible for this method to return NO, and error
318        /// will be set to nil. This occurs if the event wasn't dirty and didn't need saving. This
319        /// means the correct way to detect failure is a result of NO and a non-nil error parameter.
320        /// Passing an event fetched from another EKEventStore instance into this function will
321        /// raise an exception.
322        ///
323        /// After an event is successfully saved, it is also put into sync with the database, meaning
324        /// that all fields you did not change will be updated to the latest values. If you save the
325        /// event, but it was deleted by a different store/process, you will effectively recreate the
326        /// event as a new event.
327        ///
328        /// On WatchOS, saving changes is not supported.
329        ///
330        ///
331        /// Parameter `event`: The event to save.
332        ///
333        /// Parameter `span`: The span to use (this event, or this and future events).
334        ///
335        /// Parameter `error`: If an error occurs, this will contain a valid NSError object on exit.
336        #[unsafe(method(saveEvent:span:error:_))]
337        #[unsafe(method_family = none)]
338        pub unsafe fn saveEvent_span_error(
339            &self,
340            event: &EKEvent,
341            span: EKSpan,
342        ) -> Result<(), Retained<NSError>>;
343
344        #[cfg(all(feature = "EKCalendarItem", feature = "EKEvent", feature = "EKObject"))]
345        /// Removes an event from the calendar store.
346        ///
347        /// This method attempts to remove the event from the calendar database. It returns YES if
348        /// successful and NO otherwise. It's possible for this method to return NO, and error
349        /// will be set to nil. This occurs if the event wasn't ever added and didn't need removing. This
350        /// means the correct way to detect failure is a result of NO and a non-nil error parameter.
351        /// Passing an event from another CalendarStore into this function will raise an exception. After
352        /// an event is removed, it is no longer tied to this calendar store, and all data in the event
353        /// is cleared except for the eventIdentifier.
354        ///
355        /// On WatchOS, modifying the database is not supported.
356        ///
357        ///
358        /// Parameter `event`: The event to save.
359        ///
360        /// Parameter `span`: The span to use (this event, or this and future events).
361        ///
362        /// Parameter `error`: If an error occurs, this will contain a valid NSError object on exit.
363        #[unsafe(method(removeEvent:span:error:_))]
364        #[unsafe(method_family = none)]
365        pub unsafe fn removeEvent_span_error(
366            &self,
367            event: &EKEvent,
368            span: EKSpan,
369        ) -> Result<(), Retained<NSError>>;
370
371        #[cfg(all(feature = "EKCalendarItem", feature = "EKEvent", feature = "EKObject"))]
372        #[unsafe(method(saveEvent:span:commit:error:_))]
373        #[unsafe(method_family = none)]
374        pub unsafe fn saveEvent_span_commit_error(
375            &self,
376            event: &EKEvent,
377            span: EKSpan,
378            commit: bool,
379        ) -> Result<(), Retained<NSError>>;
380
381        #[cfg(all(feature = "EKCalendarItem", feature = "EKEvent", feature = "EKObject"))]
382        #[unsafe(method(removeEvent:span:commit:error:_))]
383        #[unsafe(method_family = none)]
384        pub unsafe fn removeEvent_span_commit_error(
385            &self,
386            event: &EKEvent,
387            span: EKSpan,
388            commit: bool,
389        ) -> Result<(), Retained<NSError>>;
390
391        #[cfg(all(feature = "EKCalendarItem", feature = "EKEvent", feature = "EKObject"))]
392        /// Returns the first occurrence of an event matching the given event identifier.
393        ///
394        ///
395        /// Parameter `identifier`: The eventIdentifier to search for.
396        ///
397        /// Returns: An EKEvent object, or nil if not found.
398        #[unsafe(method(eventWithIdentifier:))]
399        #[unsafe(method_family = none)]
400        pub unsafe fn eventWithIdentifier(
401            &self,
402            identifier: &NSString,
403        ) -> Option<Retained<EKEvent>>;
404
405        #[cfg(all(feature = "EKCalendarItem", feature = "EKEvent", feature = "EKObject"))]
406        /// Searches for events that match the given predicate.
407        ///
408        /// This call executes a search for the events indicated by the predicate passed to it.
409        ///
410        /// It is synchronous. If you want async behavior, you should either use dispatch_async or
411        /// NSOperation to run the query someplace other than the main thread, and then funnel the
412        /// array back to the main thread.
413        ///
414        ///
415        /// Parameter `predicate`: The predicate to invoke. If this predicate was not created with the predicate
416        /// creation functions in this class, an exception is raised.
417        ///
418        /// Returns: An array of EKEvent objects, or nil. There is no guaranteed order to the events.
419        #[unsafe(method(eventsMatchingPredicate:))]
420        #[unsafe(method_family = none)]
421        pub unsafe fn eventsMatchingPredicate(
422            &self,
423            predicate: &NSPredicate,
424        ) -> Retained<NSArray<EKEvent>>;
425
426        #[cfg(all(
427            feature = "EKCalendarItem",
428            feature = "EKEvent",
429            feature = "EKObject",
430            feature = "block2"
431        ))]
432        /// Searches for events that match the given predicate.
433        ///
434        /// This call executes a search for the events indicated by the predicate passed to it, calling
435        /// the block specified in the callback parameter for each event.
436        ///
437        /// This method is synchronous. If you want async behavior, you should either use dispatch_async or
438        /// NSOperation to run the query someplace other than the main thread.
439        ///
440        ///
441        /// Parameter `predicate`: The predicate to invoke. If this predicate was not created with the predicate
442        /// creation functions in this class, an exception is raised.
443        ///
444        /// Parameter `block`: The block to call for each event. Your block should return YES in the stop
445        /// parameter to stop iterating.
446        ///
447        /// # Safety
448        ///
449        /// `block` must be a valid pointer.
450        #[unsafe(method(enumerateEventsMatchingPredicate:usingBlock:))]
451        #[unsafe(method_family = none)]
452        pub unsafe fn enumerateEventsMatchingPredicate_usingBlock(
453            &self,
454            predicate: &NSPredicate,
455            block: EKEventSearchCallback,
456        );
457
458        #[cfg(all(feature = "EKCalendar", feature = "EKObject"))]
459        /// Creates a predicate for use with eventsMatchingPredicate or enumerateEventsMatchingPredicate:usingBlock:.
460        ///
461        /// Creates a simple query predicate to search for events within a certain date range. At present,
462        /// this will return events in the default time zone ([NSTimeZone defaultTimeZone]).
463        ///
464        /// For performance reasons, this method will only return events within a four year timespan.
465        /// If the date range between the startDate and endDate is greater than four years, then it will be shortened
466        /// to the first four years.
467        ///
468        ///
469        /// Parameter `startDate`: The start date.
470        ///
471        /// Parameter `endDate`: The end date.
472        ///
473        /// Parameter `calendars`: The calendars to search for events in, or nil to search all calendars.
474        #[unsafe(method(predicateForEventsWithStartDate:endDate:calendars:))]
475        #[unsafe(method_family = none)]
476        pub unsafe fn predicateForEventsWithStartDate_endDate_calendars(
477            &self,
478            start_date: &NSDate,
479            end_date: &NSDate,
480            calendars: Option<&NSArray<EKCalendar>>,
481        ) -> Retained<NSPredicate>;
482
483        #[cfg(all(
484            feature = "EKCalendarItem",
485            feature = "EKObject",
486            feature = "EKReminder"
487        ))]
488        /// Saves changes to a reminder.
489        ///
490        /// This method attempts to save the reminder to the event store database. It returns YES if
491        /// successful and NO otherwise. Passing a reminder fetched from another EKEventStore instance
492        /// into this function will raise an exception.
493        ///
494        /// After a reminder is successfully saved, its fields are updated to the latest values in
495        /// the database.
496        ///
497        /// On WatchOS, saving changes is not supported.
498        ///
499        ///
500        /// Parameter `reminder`: The reminder to save.
501        ///
502        /// Parameter `commit`: Whether to save to the database or not. Pass NO to batch changes together and
503        /// commit with [EKEventStore commit:].
504        ///
505        /// Parameter `error`: If an error occurs, this will contain a valid NSError object on exit.
506        #[unsafe(method(saveReminder:commit:error:_))]
507        #[unsafe(method_family = none)]
508        pub unsafe fn saveReminder_commit_error(
509            &self,
510            reminder: &EKReminder,
511            commit: bool,
512        ) -> Result<(), Retained<NSError>>;
513
514        #[cfg(all(
515            feature = "EKCalendarItem",
516            feature = "EKObject",
517            feature = "EKReminder"
518        ))]
519        /// Removes a reminder from the event store.
520        ///
521        /// This method attempts to remove the reminder from the event store database. It returns YES if
522        /// successful and NO otherwise. Passing a reminder from another EKEventStore into this function
523        /// will raise an exception. After a reminder is removed, it is no longer tied to this event store.
524        ///
525        /// On WatchOS, modifying the database is not supported.
526        ///
527        ///
528        /// Parameter `reminder`: The reminder to save.
529        ///
530        /// Parameter `commit`: Whether to save to the database or not. Pass NO to batch changes together and
531        /// commit with [EKEventStore commit:].
532        ///
533        /// Parameter `error`: If an error occurs, this will contain a valid NSError object on exit.
534        #[unsafe(method(removeReminder:commit:error:_))]
535        #[unsafe(method_family = none)]
536        pub unsafe fn removeReminder_commit_error(
537            &self,
538            reminder: &EKReminder,
539            commit: bool,
540        ) -> Result<(), Retained<NSError>>;
541
542        #[cfg(all(
543            feature = "EKCalendarItem",
544            feature = "EKObject",
545            feature = "EKReminder",
546            feature = "block2"
547        ))]
548        /// Fetches reminders asynchronously.
549        ///
550        /// This method fetches reminders asynchronously and returns a value which can be
551        /// used in cancelFetchRequest: to cancel the request later if desired. The completion
552        /// block is called with an array of reminders that match the given predicate (or potentially nil).
553        #[unsafe(method(fetchRemindersMatchingPredicate:completion:))]
554        #[unsafe(method_family = none)]
555        pub unsafe fn fetchRemindersMatchingPredicate_completion(
556            &self,
557            predicate: &NSPredicate,
558            completion: &block2::DynBlock<dyn Fn(*mut NSArray<EKReminder>)>,
559        ) -> Retained<AnyObject>;
560
561        /// Given a value returned from fetchRemindersMatchingPredicate, this method can be used to
562        /// cancel the request. Once called, the completion block specified in fetchReminders... will
563        /// not be called.
564        ///
565        /// # Safety
566        ///
567        /// `fetch_identifier` should be of the correct type.
568        #[unsafe(method(cancelFetchRequest:))]
569        #[unsafe(method_family = none)]
570        pub unsafe fn cancelFetchRequest(&self, fetch_identifier: &AnyObject);
571
572        #[cfg(all(feature = "EKCalendar", feature = "EKObject"))]
573        /// Fetch all reminders in a set of calendars.
574        ///
575        /// You can pass nil for calendars to fetch from all available calendars.
576        #[unsafe(method(predicateForRemindersInCalendars:))]
577        #[unsafe(method_family = none)]
578        pub unsafe fn predicateForRemindersInCalendars(
579            &self,
580            calendars: Option<&NSArray<EKCalendar>>,
581        ) -> Retained<NSPredicate>;
582
583        #[cfg(all(feature = "EKCalendar", feature = "EKObject"))]
584        /// Fetch incomplete reminders in a set of calendars.
585        ///
586        /// You can use this method to search for incomplete reminders due in a range.
587        /// You can pass nil for start date to find all reminders due before endDate.
588        /// You can pass nil for both start and end date to get all incomplete reminders
589        /// in the specified calendars.
590        /// You can pass nil for calendars to fetch from all available calendars.
591        #[unsafe(method(predicateForIncompleteRemindersWithDueDateStarting:ending:calendars:))]
592        #[unsafe(method_family = none)]
593        pub unsafe fn predicateForIncompleteRemindersWithDueDateStarting_ending_calendars(
594            &self,
595            start_date: Option<&NSDate>,
596            end_date: Option<&NSDate>,
597            calendars: Option<&NSArray<EKCalendar>>,
598        ) -> Retained<NSPredicate>;
599
600        #[cfg(all(feature = "EKCalendar", feature = "EKObject"))]
601        /// Fetch completed reminders in a set of calendars.
602        ///
603        /// You can use this method to search for reminders completed between a range of dates.
604        /// You can pass nil for start date to find all reminders completed before endDate.
605        /// You can pass nil for both start and end date to get all completed reminders
606        /// in the specified calendars.
607        /// You can pass nil for calendars to fetch from all available calendars.
608        #[unsafe(method(predicateForCompletedRemindersWithCompletionDateStarting:ending:calendars:))]
609        #[unsafe(method_family = none)]
610        pub unsafe fn predicateForCompletedRemindersWithCompletionDateStarting_ending_calendars(
611            &self,
612            start_date: Option<&NSDate>,
613            end_date: Option<&NSDate>,
614            calendars: Option<&NSArray<EKCalendar>>,
615        ) -> Retained<NSPredicate>;
616
617        /// Commits pending changes to the database.
618        ///
619        /// If you use saveCalendar/saveEvent/removeCalendar/removeEvent, etc. and you pass NO to their
620        /// parameter, you are batching changes for a later commit. This method does that commit. This
621        /// allows you to save the database only once for many additions or changes.  If you pass
622        /// YES to methods' commit parameter, then you don't need to call this method.
623        ///
624        /// This method will return YES as long as nothing went awry, even if nothing was actually
625        /// committed. If it returns NO, error should contain the reason it became unhappy.
626        ///
627        /// On WatchOS, modifying the database is not supported.
628        #[unsafe(method(commit:_))]
629        #[unsafe(method_family = none)]
630        pub unsafe fn commit(&self) -> Result<(), Retained<NSError>>;
631
632        /// Resets the event store.
633        ///
634        /// You can use this method to forget ALL changes made to the event store (all additions, all
635        /// fetched objects, etc.). It essentially is as if you released the store and then created a
636        /// new one. It brings it back to its initial state. All objects ever created/fetched, etc.
637        /// using this store are no longer connected to it and are considered invalid.
638        #[unsafe(method(reset))]
639        #[unsafe(method_family = none)]
640        pub unsafe fn reset(&self);
641
642        /// Cause a sync to potentially occur taking into account the necessity of it.
643        ///
644        /// You can call this method to pull new data from remote sources.
645        /// This only updates the event store's data.  If you want to update your objects after
646        /// refreshing the sources, you should call refresh on each of them afterwards.
647        /// On iOS and macOS, this sync only occurs if deemed necessary.
648        /// On WatchOS, initiating sync is not available. Sync will occur automatically with the paired iOS device.
649        #[unsafe(method(refreshSourcesIfNecessary))]
650        #[unsafe(method_family = none)]
651        pub unsafe fn refreshSourcesIfNecessary(&self);
652    );
653}
654
655/// Methods declared on superclass `NSObject`.
656impl EKEventStore {
657    extern_methods!(
658        #[unsafe(method(new))]
659        #[unsafe(method_family = new)]
660        pub unsafe fn new() -> Retained<Self>;
661    );
662}
663
664extern "C" {
665    /// Notification name sent out when the database is changed by either an external process,
666    /// another event store in the same process, or by calling saveEvent: or removeEvent: on a
667    /// store you are managing. When you receive this notification, you should consider all EKEvent
668    /// instances you have to be invalid. If you had selected events for a date range using
669    /// eventsMatchingPredicate, etc. for display, you should release them and re-fetch the events
670    /// again. If you have an event you are actively using (e.g. you are currently viewing details
671    /// for it or editing it), you can call [EKEvent refresh] to try to revalidate it against the
672    /// latest state of the database. If that method returns YES, you can continue to use the event,
673    /// otherwise, you should release it and abandon what you were doing with it. The view
674    /// controllers provided by EventKitUI automatically deal with this for you.
675    /// This notification will also be posted if access to events or reminders is changed by the user.
676    ///
677    /// See also [Apple's documentation](https://developer.apple.com/documentation/eventkit/ekeventstorechangednotification?language=objc)
678    pub static EKEventStoreChangedNotification: &'static NSString;
679}