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