objc2_ui_kit/generated/
UICollectionView.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::*;
6#[cfg(feature = "objc2-core-foundation")]
7use objc2_core_foundation::*;
8use objc2_foundation::*;
9#[cfg(feature = "objc2-quartz-core")]
10#[cfg(not(target_os = "watchos"))]
11use objc2_quartz_core::*;
12
13use crate::*;
14
15/// [Apple's documentation](https://developer.apple.com/documentation/uikit/uicollectionviewscrollposition?language=objc)
16// NS_OPTIONS
17#[repr(transparent)]
18#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
19pub struct UICollectionViewScrollPosition(pub NSUInteger);
20bitflags::bitflags! {
21    impl UICollectionViewScrollPosition: NSUInteger {
22        #[doc(alias = "UICollectionViewScrollPositionNone")]
23        const None = 0;
24        #[doc(alias = "UICollectionViewScrollPositionTop")]
25        const Top = 1<<0;
26        #[doc(alias = "UICollectionViewScrollPositionCenteredVertically")]
27        const CenteredVertically = 1<<1;
28        #[doc(alias = "UICollectionViewScrollPositionBottom")]
29        const Bottom = 1<<2;
30        #[doc(alias = "UICollectionViewScrollPositionLeft")]
31        const Left = 1<<3;
32        #[doc(alias = "UICollectionViewScrollPositionCenteredHorizontally")]
33        const CenteredHorizontally = 1<<4;
34        #[doc(alias = "UICollectionViewScrollPositionRight")]
35        const Right = 1<<5;
36    }
37}
38
39unsafe impl Encode for UICollectionViewScrollPosition {
40    const ENCODING: Encoding = NSUInteger::ENCODING;
41}
42
43unsafe impl RefEncode for UICollectionViewScrollPosition {
44    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
45}
46
47/// [Apple's documentation](https://developer.apple.com/documentation/uikit/uicollectionviewreorderingcadence?language=objc)
48// NS_ENUM
49#[repr(transparent)]
50#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
51pub struct UICollectionViewReorderingCadence(pub NSInteger);
52impl UICollectionViewReorderingCadence {
53    #[doc(alias = "UICollectionViewReorderingCadenceImmediate")]
54    pub const Immediate: Self = Self(0);
55    #[doc(alias = "UICollectionViewReorderingCadenceFast")]
56    pub const Fast: Self = Self(1);
57    #[doc(alias = "UICollectionViewReorderingCadenceSlow")]
58    pub const Slow: Self = Self(2);
59}
60
61unsafe impl Encode for UICollectionViewReorderingCadence {
62    const ENCODING: Encoding = NSInteger::ENCODING;
63}
64
65unsafe impl RefEncode for UICollectionViewReorderingCadence {
66    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
67}
68
69/// [Apple's documentation](https://developer.apple.com/documentation/uikit/uicollectionviewselfsizinginvalidation?language=objc)
70// NS_ENUM
71#[repr(transparent)]
72#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
73pub struct UICollectionViewSelfSizingInvalidation(pub NSInteger);
74impl UICollectionViewSelfSizingInvalidation {
75    /// No updates will take place when -invalidateIntrinsicContentSize is called on a self-sizing cell or its contentView.
76    #[doc(alias = "UICollectionViewSelfSizingInvalidationDisabled")]
77    pub const Disabled: Self = Self(0);
78    /// Calling -invalidateIntrinsicContentSize on a self-sizing cell or its contentView will cause it to be resized if necessary.
79    #[doc(alias = "UICollectionViewSelfSizingInvalidationEnabled")]
80    pub const Enabled: Self = Self(1);
81    /// Calling -invalidateIntrinsicContentSize on a self-sizing cell or its contentView will cause it to be resized if necessary, and
82    /// any Auto Layout changes within the contentView of a self-sizing cell will automatically trigger -invalidateIntrinsicContentSize.
83    #[doc(alias = "UICollectionViewSelfSizingInvalidationEnabledIncludingConstraints")]
84    pub const EnabledIncludingConstraints: Self = Self(2);
85}
86
87unsafe impl Encode for UICollectionViewSelfSizingInvalidation {
88    const ENCODING: Encoding = NSInteger::ENCODING;
89}
90
91unsafe impl RefEncode for UICollectionViewSelfSizingInvalidation {
92    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
93}
94
95/// [Apple's documentation](https://developer.apple.com/documentation/uikit/uicollectionviewlayoutinteractivetransitioncompletion?language=objc)
96#[cfg(feature = "block2")]
97pub type UICollectionViewLayoutInteractiveTransitionCompletion =
98    *mut block2::DynBlock<dyn Fn(Bool, Bool)>;
99
100extern_class!(
101    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uicollectionviewfocusupdatecontext?language=objc)
102    #[unsafe(super(UIFocusUpdateContext, NSObject))]
103    #[thread_kind = MainThreadOnly]
104    #[derive(Debug, PartialEq, Eq, Hash)]
105    #[cfg(feature = "UIFocus")]
106    pub struct UICollectionViewFocusUpdateContext;
107);
108
109#[cfg(feature = "UIFocus")]
110extern_conformance!(
111    unsafe impl NSObjectProtocol for UICollectionViewFocusUpdateContext {}
112);
113
114#[cfg(feature = "UIFocus")]
115impl UICollectionViewFocusUpdateContext {
116    extern_methods!(
117        #[unsafe(method(previouslyFocusedIndexPath))]
118        #[unsafe(method_family = none)]
119        pub fn previouslyFocusedIndexPath(&self) -> Option<Retained<NSIndexPath>>;
120
121        #[unsafe(method(nextFocusedIndexPath))]
122        #[unsafe(method_family = none)]
123        pub fn nextFocusedIndexPath(&self) -> Option<Retained<NSIndexPath>>;
124    );
125}
126
127/// Methods declared on superclass `NSObject`.
128#[cfg(feature = "UIFocus")]
129impl UICollectionViewFocusUpdateContext {
130    extern_methods!(
131        #[unsafe(method(init))]
132        #[unsafe(method_family = init)]
133        pub fn init(this: Allocated<Self>) -> Retained<Self>;
134
135        #[unsafe(method(new))]
136        #[unsafe(method_family = new)]
137        pub fn new(mtm: MainThreadMarker) -> Retained<Self>;
138    );
139}
140
141extern_protocol!(
142    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uicollectionviewdatasource?language=objc)
143    pub unsafe trait UICollectionViewDataSource: NSObjectProtocol + MainThreadOnly {
144        #[cfg(all(feature = "UIResponder", feature = "UIScrollView", feature = "UIView"))]
145        #[unsafe(method(collectionView:numberOfItemsInSection:))]
146        #[unsafe(method_family = none)]
147        fn collectionView_numberOfItemsInSection(
148            &self,
149            collection_view: &UICollectionView,
150            section: NSInteger,
151        ) -> NSInteger;
152
153        #[cfg(all(
154            feature = "UICollectionViewCell",
155            feature = "UIResponder",
156            feature = "UIScrollView",
157            feature = "UIView"
158        ))]
159        #[unsafe(method(collectionView:cellForItemAtIndexPath:))]
160        #[unsafe(method_family = none)]
161        fn collectionView_cellForItemAtIndexPath(
162            &self,
163            collection_view: &UICollectionView,
164            index_path: &NSIndexPath,
165        ) -> Retained<UICollectionViewCell>;
166
167        #[cfg(all(feature = "UIResponder", feature = "UIScrollView", feature = "UIView"))]
168        #[optional]
169        #[unsafe(method(numberOfSectionsInCollectionView:))]
170        #[unsafe(method_family = none)]
171        fn numberOfSectionsInCollectionView(&self, collection_view: &UICollectionView)
172            -> NSInteger;
173
174        #[cfg(all(
175            feature = "UICollectionViewCell",
176            feature = "UIResponder",
177            feature = "UIScrollView",
178            feature = "UIView"
179        ))]
180        #[optional]
181        #[unsafe(method(collectionView:viewForSupplementaryElementOfKind:atIndexPath:))]
182        #[unsafe(method_family = none)]
183        fn collectionView_viewForSupplementaryElementOfKind_atIndexPath(
184            &self,
185            collection_view: &UICollectionView,
186            kind: &NSString,
187            index_path: &NSIndexPath,
188        ) -> Retained<UICollectionReusableView>;
189
190        #[cfg(all(feature = "UIResponder", feature = "UIScrollView", feature = "UIView"))]
191        #[optional]
192        #[unsafe(method(collectionView:canMoveItemAtIndexPath:))]
193        #[unsafe(method_family = none)]
194        fn collectionView_canMoveItemAtIndexPath(
195            &self,
196            collection_view: &UICollectionView,
197            index_path: &NSIndexPath,
198        ) -> bool;
199
200        #[cfg(all(feature = "UIResponder", feature = "UIScrollView", feature = "UIView"))]
201        #[optional]
202        #[unsafe(method(collectionView:moveItemAtIndexPath:toIndexPath:))]
203        #[unsafe(method_family = none)]
204        fn collectionView_moveItemAtIndexPath_toIndexPath(
205            &self,
206            collection_view: &UICollectionView,
207            source_index_path: &NSIndexPath,
208            destination_index_path: &NSIndexPath,
209        );
210
211        #[cfg(all(feature = "UIResponder", feature = "UIScrollView", feature = "UIView"))]
212        /// Returns a list of index titles to display in the index view (e.g. ["A", "B", "C" ... "Z", "#"])
213        #[optional]
214        #[unsafe(method(indexTitlesForCollectionView:))]
215        #[unsafe(method_family = none)]
216        fn indexTitlesForCollectionView(
217            &self,
218            collection_view: &UICollectionView,
219        ) -> Option<Retained<NSArray<NSString>>>;
220
221        #[cfg(all(feature = "UIResponder", feature = "UIScrollView", feature = "UIView"))]
222        /// Returns the index path that corresponds to the given title / index. (e.g. "B",1)
223        /// Return an index path with a single index to indicate an entire section, instead of a specific item.
224        #[optional]
225        #[unsafe(method(collectionView:indexPathForIndexTitle:atIndex:))]
226        #[unsafe(method_family = none)]
227        fn collectionView_indexPathForIndexTitle_atIndex(
228            &self,
229            collection_view: &UICollectionView,
230            title: &NSString,
231            index: NSInteger,
232        ) -> Retained<NSIndexPath>;
233    }
234);
235
236extern_protocol!(
237    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uicollectionviewdatasourceprefetching?language=objc)
238    pub unsafe trait UICollectionViewDataSourcePrefetching:
239        NSObjectProtocol + MainThreadOnly
240    {
241        #[cfg(all(feature = "UIResponder", feature = "UIScrollView", feature = "UIView"))]
242        #[unsafe(method(collectionView:prefetchItemsAtIndexPaths:))]
243        #[unsafe(method_family = none)]
244        fn collectionView_prefetchItemsAtIndexPaths(
245            &self,
246            collection_view: &UICollectionView,
247            index_paths: &NSArray<NSIndexPath>,
248        );
249
250        #[cfg(all(feature = "UIResponder", feature = "UIScrollView", feature = "UIView"))]
251        #[optional]
252        #[unsafe(method(collectionView:cancelPrefetchingForItemsAtIndexPaths:))]
253        #[unsafe(method_family = none)]
254        fn collectionView_cancelPrefetchingForItemsAtIndexPaths(
255            &self,
256            collection_view: &UICollectionView,
257            index_paths: &NSArray<NSIndexPath>,
258        );
259    }
260);
261
262extern_protocol!(
263    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uicollectionviewdelegate?language=objc)
264    #[cfg(feature = "UIScrollView")]
265    pub unsafe trait UICollectionViewDelegate:
266        UIScrollViewDelegate + MainThreadOnly
267    {
268        #[cfg(all(feature = "UIResponder", feature = "UIView"))]
269        #[optional]
270        #[unsafe(method(collectionView:shouldHighlightItemAtIndexPath:))]
271        #[unsafe(method_family = none)]
272        fn collectionView_shouldHighlightItemAtIndexPath(
273            &self,
274            collection_view: &UICollectionView,
275            index_path: &NSIndexPath,
276        ) -> bool;
277
278        #[cfg(all(feature = "UIResponder", feature = "UIView"))]
279        #[optional]
280        #[unsafe(method(collectionView:didHighlightItemAtIndexPath:))]
281        #[unsafe(method_family = none)]
282        fn collectionView_didHighlightItemAtIndexPath(
283            &self,
284            collection_view: &UICollectionView,
285            index_path: &NSIndexPath,
286        );
287
288        #[cfg(all(feature = "UIResponder", feature = "UIView"))]
289        #[optional]
290        #[unsafe(method(collectionView:didUnhighlightItemAtIndexPath:))]
291        #[unsafe(method_family = none)]
292        fn collectionView_didUnhighlightItemAtIndexPath(
293            &self,
294            collection_view: &UICollectionView,
295            index_path: &NSIndexPath,
296        );
297
298        #[cfg(all(feature = "UIResponder", feature = "UIView"))]
299        #[optional]
300        #[unsafe(method(collectionView:shouldSelectItemAtIndexPath:))]
301        #[unsafe(method_family = none)]
302        fn collectionView_shouldSelectItemAtIndexPath(
303            &self,
304            collection_view: &UICollectionView,
305            index_path: &NSIndexPath,
306        ) -> bool;
307
308        #[cfg(all(feature = "UIResponder", feature = "UIView"))]
309        #[optional]
310        #[unsafe(method(collectionView:shouldDeselectItemAtIndexPath:))]
311        #[unsafe(method_family = none)]
312        fn collectionView_shouldDeselectItemAtIndexPath(
313            &self,
314            collection_view: &UICollectionView,
315            index_path: &NSIndexPath,
316        ) -> bool;
317
318        #[cfg(all(feature = "UIResponder", feature = "UIView"))]
319        #[optional]
320        #[unsafe(method(collectionView:didSelectItemAtIndexPath:))]
321        #[unsafe(method_family = none)]
322        fn collectionView_didSelectItemAtIndexPath(
323            &self,
324            collection_view: &UICollectionView,
325            index_path: &NSIndexPath,
326        );
327
328        #[cfg(all(feature = "UIResponder", feature = "UIView"))]
329        #[optional]
330        #[unsafe(method(collectionView:didDeselectItemAtIndexPath:))]
331        #[unsafe(method_family = none)]
332        fn collectionView_didDeselectItemAtIndexPath(
333            &self,
334            collection_view: &UICollectionView,
335            index_path: &NSIndexPath,
336        );
337
338        #[cfg(all(feature = "UIResponder", feature = "UIView"))]
339        /// Called to determine if a primary action can be performed for the item at the given indexPath.
340        /// See
341        /// `collectionView:performPrimaryActionForItemAtIndexPath:`for more details about primary actions.
342        ///
343        ///
344        /// Parameter `collectionView`: This UICollectionView
345        ///
346        /// Parameter `indexPath`: NSIndexPath of the item
347        ///
348        ///
349        /// Returns: `YES` if the primary action can be performed; otherwise `NO`. If not implemented, defaults to `YES` when not editing
350        /// and `NO` when editing.
351        #[optional]
352        #[unsafe(method(collectionView:canPerformPrimaryActionForItemAtIndexPath:))]
353        #[unsafe(method_family = none)]
354        fn collectionView_canPerformPrimaryActionForItemAtIndexPath(
355            &self,
356            collection_view: &UICollectionView,
357            index_path: &NSIndexPath,
358        ) -> bool;
359
360        #[cfg(all(feature = "UIResponder", feature = "UIView"))]
361        /// Called when the primary action should be performed for the item at the given indexPath.
362        ///
363        ///
364        /// Primary actions allow you to distinguish between a change of selection (which can be based on focus changes or
365        /// other indirect selection changes) and distinct user actions. Primary actions are performed when the user selects a cell without extending
366        /// an existing selection. This is called after
367        /// `shouldSelectItem`and
368        /// `didSelectItem`, regardless of whether the cell's selection
369        /// state was allowed to change.
370        ///
371        /// As an example, use
372        /// `didSelectItemAtIndexPath`for updating state in the current view controller (i.e. buttons, title, etc) and
373        /// use the primary action for navigation or showing another split view column.
374        ///
375        ///
376        /// Parameter `collectionView`: This UICollectionView
377        ///
378        /// Parameter `indexPath`: NSIndexPath of the item to perform the action on
379        #[optional]
380        #[unsafe(method(collectionView:performPrimaryActionForItemAtIndexPath:))]
381        #[unsafe(method_family = none)]
382        fn collectionView_performPrimaryActionForItemAtIndexPath(
383            &self,
384            collection_view: &UICollectionView,
385            index_path: &NSIndexPath,
386        );
387
388        #[cfg(all(
389            feature = "UICollectionViewCell",
390            feature = "UIResponder",
391            feature = "UIView"
392        ))]
393        #[optional]
394        #[unsafe(method(collectionView:willDisplayCell:forItemAtIndexPath:))]
395        #[unsafe(method_family = none)]
396        fn collectionView_willDisplayCell_forItemAtIndexPath(
397            &self,
398            collection_view: &UICollectionView,
399            cell: &UICollectionViewCell,
400            index_path: &NSIndexPath,
401        );
402
403        #[cfg(all(
404            feature = "UICollectionViewCell",
405            feature = "UIResponder",
406            feature = "UIView"
407        ))]
408        #[optional]
409        #[unsafe(method(collectionView:willDisplaySupplementaryView:forElementKind:atIndexPath:))]
410        #[unsafe(method_family = none)]
411        fn collectionView_willDisplaySupplementaryView_forElementKind_atIndexPath(
412            &self,
413            collection_view: &UICollectionView,
414            view: &UICollectionReusableView,
415            element_kind: &NSString,
416            index_path: &NSIndexPath,
417        );
418
419        #[cfg(all(
420            feature = "UICollectionViewCell",
421            feature = "UIResponder",
422            feature = "UIView"
423        ))]
424        #[optional]
425        #[unsafe(method(collectionView:didEndDisplayingCell:forItemAtIndexPath:))]
426        #[unsafe(method_family = none)]
427        fn collectionView_didEndDisplayingCell_forItemAtIndexPath(
428            &self,
429            collection_view: &UICollectionView,
430            cell: &UICollectionViewCell,
431            index_path: &NSIndexPath,
432        );
433
434        #[cfg(all(
435            feature = "UICollectionViewCell",
436            feature = "UIResponder",
437            feature = "UIView"
438        ))]
439        #[optional]
440        #[unsafe(method(collectionView:didEndDisplayingSupplementaryView:forElementOfKind:atIndexPath:))]
441        #[unsafe(method_family = none)]
442        fn collectionView_didEndDisplayingSupplementaryView_forElementOfKind_atIndexPath(
443            &self,
444            collection_view: &UICollectionView,
445            view: &UICollectionReusableView,
446            element_kind: &NSString,
447            index_path: &NSIndexPath,
448        );
449
450        #[cfg(all(feature = "UIResponder", feature = "UIView"))]
451        #[deprecated]
452        #[optional]
453        #[unsafe(method(collectionView:shouldShowMenuForItemAtIndexPath:))]
454        #[unsafe(method_family = none)]
455        fn collectionView_shouldShowMenuForItemAtIndexPath(
456            &self,
457            collection_view: &UICollectionView,
458            index_path: &NSIndexPath,
459        ) -> bool;
460
461        #[cfg(all(feature = "UIResponder", feature = "UIView"))]
462        /// # Safety
463        ///
464        /// - `action` must be a valid selector.
465        /// - `sender` should be of the correct type.
466        #[deprecated]
467        #[optional]
468        #[unsafe(method(collectionView:canPerformAction:forItemAtIndexPath:withSender:))]
469        #[unsafe(method_family = none)]
470        unsafe fn collectionView_canPerformAction_forItemAtIndexPath_withSender(
471            &self,
472            collection_view: &UICollectionView,
473            action: Sel,
474            index_path: &NSIndexPath,
475            sender: Option<&AnyObject>,
476        ) -> bool;
477
478        #[cfg(all(feature = "UIResponder", feature = "UIView"))]
479        /// # Safety
480        ///
481        /// - `action` must be a valid selector.
482        /// - `sender` should be of the correct type.
483        #[deprecated]
484        #[optional]
485        #[unsafe(method(collectionView:performAction:forItemAtIndexPath:withSender:))]
486        #[unsafe(method_family = none)]
487        unsafe fn collectionView_performAction_forItemAtIndexPath_withSender(
488            &self,
489            collection_view: &UICollectionView,
490            action: Sel,
491            index_path: &NSIndexPath,
492            sender: Option<&AnyObject>,
493        );
494
495        #[cfg(all(
496            feature = "UICollectionViewLayout",
497            feature = "UICollectionViewTransitionLayout",
498            feature = "UIResponder",
499            feature = "UIView"
500        ))]
501        #[optional]
502        #[unsafe(method(collectionView:transitionLayoutForOldLayout:newLayout:))]
503        #[unsafe(method_family = none)]
504        fn collectionView_transitionLayoutForOldLayout_newLayout(
505            &self,
506            collection_view: &UICollectionView,
507            from_layout: &UICollectionViewLayout,
508            to_layout: &UICollectionViewLayout,
509        ) -> Retained<UICollectionViewTransitionLayout>;
510
511        #[cfg(all(feature = "UIResponder", feature = "UIView"))]
512        #[optional]
513        #[unsafe(method(collectionView:canFocusItemAtIndexPath:))]
514        #[unsafe(method_family = none)]
515        fn collectionView_canFocusItemAtIndexPath(
516            &self,
517            collection_view: &UICollectionView,
518            index_path: &NSIndexPath,
519        ) -> bool;
520
521        #[cfg(all(feature = "UIFocus", feature = "UIResponder", feature = "UIView"))]
522        #[optional]
523        #[unsafe(method(collectionView:shouldUpdateFocusInContext:))]
524        #[unsafe(method_family = none)]
525        fn collectionView_shouldUpdateFocusInContext(
526            &self,
527            collection_view: &UICollectionView,
528            context: &UICollectionViewFocusUpdateContext,
529        ) -> bool;
530
531        #[cfg(all(
532            feature = "UIFocus",
533            feature = "UIFocusAnimationCoordinator",
534            feature = "UIResponder",
535            feature = "UIView"
536        ))]
537        #[optional]
538        #[unsafe(method(collectionView:didUpdateFocusInContext:withAnimationCoordinator:))]
539        #[unsafe(method_family = none)]
540        fn collectionView_didUpdateFocusInContext_withAnimationCoordinator(
541            &self,
542            collection_view: &UICollectionView,
543            context: &UICollectionViewFocusUpdateContext,
544            coordinator: &UIFocusAnimationCoordinator,
545        );
546
547        #[cfg(all(feature = "UIResponder", feature = "UIView"))]
548        #[optional]
549        #[unsafe(method(indexPathForPreferredFocusedViewInCollectionView:))]
550        #[unsafe(method_family = none)]
551        fn indexPathForPreferredFocusedViewInCollectionView(
552            &self,
553            collection_view: &UICollectionView,
554        ) -> Option<Retained<NSIndexPath>>;
555
556        #[cfg(all(feature = "UIResponder", feature = "UIView"))]
557        /// Determines if the item at the specified index path should also become selected when focus moves to it.
558        /// If the collection view's global selectionFollowsFocus is enabled, this method will allow you to override that behavior on a per-index path basis. This method is not called if selectionFollowsFocus is disabled.
559        #[optional]
560        #[unsafe(method(collectionView:selectionFollowsFocusForItemAtIndexPath:))]
561        #[unsafe(method_family = none)]
562        fn collectionView_selectionFollowsFocusForItemAtIndexPath(
563            &self,
564            collection_view: &UICollectionView,
565            index_path: &NSIndexPath,
566        ) -> bool;
567
568        #[cfg(all(feature = "UIResponder", feature = "UIView"))]
569        #[optional]
570        #[unsafe(method(collectionView:targetIndexPathForMoveOfItemFromOriginalIndexPath:atCurrentIndexPath:toProposedIndexPath:))]
571        #[unsafe(method_family = none)]
572        fn collectionView_targetIndexPathForMoveOfItemFromOriginalIndexPath_atCurrentIndexPath_toProposedIndexPath(
573            &self,
574            collection_view: &UICollectionView,
575            original_index_path: &NSIndexPath,
576            current_index_path: &NSIndexPath,
577            proposed_index_path: &NSIndexPath,
578        ) -> Retained<NSIndexPath>;
579
580        #[cfg(all(feature = "UIResponder", feature = "UIView"))]
581        #[deprecated]
582        #[optional]
583        #[unsafe(method(collectionView:targetIndexPathForMoveFromItemAtIndexPath:toProposedIndexPath:))]
584        #[unsafe(method_family = none)]
585        fn collectionView_targetIndexPathForMoveFromItemAtIndexPath_toProposedIndexPath(
586            &self,
587            collection_view: &UICollectionView,
588            current_index_path: &NSIndexPath,
589            proposed_index_path: &NSIndexPath,
590        ) -> Retained<NSIndexPath>;
591
592        #[cfg(all(
593            feature = "UIResponder",
594            feature = "UIView",
595            feature = "objc2-core-foundation"
596        ))]
597        #[optional]
598        #[unsafe(method(collectionView:targetContentOffsetForProposedContentOffset:))]
599        #[unsafe(method_family = none)]
600        fn collectionView_targetContentOffsetForProposedContentOffset(
601            &self,
602            collection_view: &UICollectionView,
603            proposed_content_offset: CGPoint,
604        ) -> CGPoint;
605
606        #[cfg(all(feature = "UIResponder", feature = "UIView"))]
607        #[optional]
608        #[unsafe(method(collectionView:canEditItemAtIndexPath:))]
609        #[unsafe(method_family = none)]
610        fn collectionView_canEditItemAtIndexPath(
611            &self,
612            collection_view: &UICollectionView,
613            index_path: &NSIndexPath,
614        ) -> bool;
615
616        #[cfg(all(
617            feature = "UIResponder",
618            feature = "UISpringLoadedInteraction",
619            feature = "UIView"
620        ))]
621        #[optional]
622        #[unsafe(method(collectionView:shouldSpringLoadItemAtIndexPath:withContext:))]
623        #[unsafe(method_family = none)]
624        fn collectionView_shouldSpringLoadItemAtIndexPath_withContext(
625            &self,
626            collection_view: &UICollectionView,
627            index_path: &NSIndexPath,
628            context: &ProtocolObject<dyn UISpringLoadedInteractionContext>,
629        ) -> bool;
630
631        #[cfg(all(feature = "UIResponder", feature = "UIView"))]
632        #[optional]
633        #[unsafe(method(collectionView:shouldBeginMultipleSelectionInteractionAtIndexPath:))]
634        #[unsafe(method_family = none)]
635        fn collectionView_shouldBeginMultipleSelectionInteractionAtIndexPath(
636            &self,
637            collection_view: &UICollectionView,
638            index_path: &NSIndexPath,
639        ) -> bool;
640
641        #[cfg(all(feature = "UIResponder", feature = "UIView"))]
642        #[optional]
643        #[unsafe(method(collectionView:didBeginMultipleSelectionInteractionAtIndexPath:))]
644        #[unsafe(method_family = none)]
645        fn collectionView_didBeginMultipleSelectionInteractionAtIndexPath(
646            &self,
647            collection_view: &UICollectionView,
648            index_path: &NSIndexPath,
649        );
650
651        #[cfg(all(feature = "UIResponder", feature = "UIView"))]
652        #[optional]
653        #[unsafe(method(collectionViewDidEndMultipleSelectionInteraction:))]
654        #[unsafe(method_family = none)]
655        fn collectionViewDidEndMultipleSelectionInteraction(
656            &self,
657            collection_view: &UICollectionView,
658        );
659
660        #[cfg(all(
661            feature = "UIContextMenuConfiguration",
662            feature = "UIResponder",
663            feature = "UIView",
664            feature = "objc2-core-foundation"
665        ))]
666        /// Called when a context menu is invoked from this collection view.
667        ///
668        ///
669        /// Parameter `collectionView`: The
670        /// `UICollectionView.`
671        /// Parameter `indexPaths`: An array of index paths on which the menu acts.
672        ///
673        /// Parameter `point`: Touch location in the collection view's coordinate space.
674        ///
675        ///
676        /// Returns: A
677        /// `UIContextMenuConfiguration`describing the menu to be presented. Return nil to prevent the interaction from beginning.
678        /// Returning an empty configuration causes the interaction to begin then fail with a cancellation effect. You might use this
679        /// to indicate to users that it's possible for a menu to be presented from this element, but that there are no actions to
680        /// present at this particular time.
681        ///
682        ///
683        /// The
684        /// `indexPaths`array may contain 0-many items:
685        /// - An empty array indicates that the menu was invoked in the space between cells (or any location that does not map to an item index path).
686        /// - An array with multiple index paths indicates that the menu was invoked on an item within a multiple selection.
687        #[optional]
688        #[unsafe(method(collectionView:contextMenuConfigurationForItemsAtIndexPaths:point:))]
689        #[unsafe(method_family = none)]
690        fn collectionView_contextMenuConfigurationForItemsAtIndexPaths_point(
691            &self,
692            collection_view: &UICollectionView,
693            index_paths: &NSArray<NSIndexPath>,
694            point: CGPoint,
695        ) -> Option<Retained<UIContextMenuConfiguration>>;
696
697        #[cfg(all(
698            feature = "UIContextMenuConfiguration",
699            feature = "UIResponder",
700            feature = "UITargetedPreview",
701            feature = "UIView"
702        ))]
703        /// Called when a context menu interaction begins in this collection view to request a preview for the interaction's initial highlight effect.
704        /// Return a
705        /// `UITargetedPreview`corresponding to the item at the given indexPath.
706        ///
707        ///
708        /// Parameter `collectionView`: The
709        /// `UICollectionView.`
710        /// Parameter `configuration`: Configuration of the menu that will be presented if the interaction proceeds.
711        ///
712        /// Parameter `indexPath`: Index path of the item at which the interaction is occurring.
713        #[optional]
714        #[unsafe(method(collectionView:contextMenuConfiguration:highlightPreviewForItemAtIndexPath:))]
715        #[unsafe(method_family = none)]
716        fn collectionView_contextMenuConfiguration_highlightPreviewForItemAtIndexPath(
717            &self,
718            collection_view: &UICollectionView,
719            configuration: &UIContextMenuConfiguration,
720            index_path: &NSIndexPath,
721        ) -> Option<Retained<UITargetedPreview>>;
722
723        #[cfg(all(
724            feature = "UIContextMenuConfiguration",
725            feature = "UIResponder",
726            feature = "UITargetedPreview",
727            feature = "UIView"
728        ))]
729        /// Called when a context menu presented from this collection view is dismissed. Return a
730        /// `UITargetedPreview`corresponding to the item at the given indexPath.
731        ///
732        ///
733        /// Parameter `collectionView`: The
734        /// `UICollectionView.`
735        /// Parameter `configuration`: Configuration of the menu being dismissed.
736        ///
737        /// Parameter `indexPath`: Index path of the item to which the menu is being dismissed.
738        #[optional]
739        #[unsafe(method(collectionView:contextMenuConfiguration:dismissalPreviewForItemAtIndexPath:))]
740        #[unsafe(method_family = none)]
741        fn collectionView_contextMenuConfiguration_dismissalPreviewForItemAtIndexPath(
742            &self,
743            collection_view: &UICollectionView,
744            configuration: &UIContextMenuConfiguration,
745            index_path: &NSIndexPath,
746        ) -> Option<Retained<UITargetedPreview>>;
747
748        #[cfg(all(
749            feature = "UIContextMenuConfiguration",
750            feature = "UIContextMenuInteraction",
751            feature = "UIResponder",
752            feature = "UIView"
753        ))]
754        /// Called when the interaction is about to "commit" in response to the user tapping the preview.
755        ///
756        ///
757        /// Parameter `collectionView`: The
758        /// `UICollectionView.`
759        /// Parameter `configuration`: Configuration of the currently displayed menu.
760        ///
761        /// Parameter `animator`: Commit animator. Add animations to this object to run them alongside the commit transition.
762        #[optional]
763        #[unsafe(method(collectionView:willPerformPreviewActionForMenuWithConfiguration:animator:))]
764        #[unsafe(method_family = none)]
765        fn collectionView_willPerformPreviewActionForMenuWithConfiguration_animator(
766            &self,
767            collection_view: &UICollectionView,
768            configuration: &UIContextMenuConfiguration,
769            animator: &ProtocolObject<dyn UIContextMenuInteractionCommitAnimating>,
770        );
771
772        #[cfg(all(
773            feature = "UIContextMenuConfiguration",
774            feature = "UIContextMenuInteraction",
775            feature = "UIResponder",
776            feature = "UIView"
777        ))]
778        /// Called when the collection view is about to display a menu.
779        ///
780        ///
781        /// Parameter `collectionView`: The
782        /// `UICollectionView.`
783        /// Parameter `configuration`: The configuration of the menu about to be displayed.
784        ///
785        /// Parameter `animator`: Appearance animator. Add animations to run them alongside the appearance transition.
786        #[optional]
787        #[unsafe(method(collectionView:willDisplayContextMenuWithConfiguration:animator:))]
788        #[unsafe(method_family = none)]
789        fn collectionView_willDisplayContextMenuWithConfiguration_animator(
790            &self,
791            collection_view: &UICollectionView,
792            configuration: &UIContextMenuConfiguration,
793            animator: Option<&ProtocolObject<dyn UIContextMenuInteractionAnimating>>,
794        );
795
796        #[cfg(all(
797            feature = "UIContextMenuConfiguration",
798            feature = "UIContextMenuInteraction",
799            feature = "UIResponder",
800            feature = "UIView"
801        ))]
802        /// Called when the collection view's context menu interaction is about to end.
803        ///
804        ///
805        /// Parameter `collectionView`: The
806        /// `UICollectionView.`
807        /// Parameter `configuration`: Ending configuration.
808        ///
809        /// Parameter `animator`: Disappearance animator. Add animations to run them alongside the disappearance transition.
810        #[optional]
811        #[unsafe(method(collectionView:willEndContextMenuInteractionWithConfiguration:animator:))]
812        #[unsafe(method_family = none)]
813        fn collectionView_willEndContextMenuInteractionWithConfiguration_animator(
814            &self,
815            collection_view: &UICollectionView,
816            configuration: &UIContextMenuConfiguration,
817            animator: Option<&ProtocolObject<dyn UIContextMenuInteractionAnimating>>,
818        );
819
820        #[cfg(all(
821            feature = "UIResponder",
822            feature = "UIView",
823            feature = "UIWindowSceneActivationConfiguration",
824            feature = "objc2-core-foundation"
825        ))]
826        /// Return a valid
827        /// `UIWindowSceneActivationConfiguration`to allow for the cell to be expanded into a new scene. Return nil to prevent the interaction from starting.
828        ///
829        ///
830        /// Parameter `collectionView`: The collection view
831        ///
832        /// Parameter `indexPath`: The index path of the cell being interacted with
833        ///
834        /// Parameter `point`: The centroid of the interaction in the collection view's coordinate space.
835        #[optional]
836        #[unsafe(method(collectionView:sceneActivationConfigurationForItemAtIndexPath:point:))]
837        #[unsafe(method_family = none)]
838        fn collectionView_sceneActivationConfigurationForItemAtIndexPath_point(
839            &self,
840            collection_view: &UICollectionView,
841            index_path: &NSIndexPath,
842            point: CGPoint,
843        ) -> Option<Retained<UIWindowSceneActivationConfiguration>>;
844
845        #[cfg(all(
846            feature = "UIContextMenuConfiguration",
847            feature = "UIResponder",
848            feature = "UIView",
849            feature = "objc2-core-foundation"
850        ))]
851        /// Called when the interaction begins.
852        ///
853        ///
854        /// Parameter `collectionView`: The
855        /// `UICollectionView.`
856        /// Parameter `indexPath`: IndexPath of the item for which a configuration is being requested.
857        ///
858        /// Parameter `point`: Touch location in the collection view's coordinate space
859        ///
860        ///
861        /// Returns: A UIContextMenuConfiguration describing the menu to be presented. Return nil to prevent the interaction from beginning.
862        /// Returning an empty configuration causes the interaction to begin then fail with a cancellation effect. You might use this
863        /// to indicate to users that it's possible for a menu to be presented from this element, but that there are no actions to
864        /// present at this particular time. If the non-deprecated replacement for the configuration, highlight preview, or dismissal preview methods is implemented this method is not called.
865        #[deprecated]
866        #[optional]
867        #[unsafe(method(collectionView:contextMenuConfigurationForItemAtIndexPath:point:))]
868        #[unsafe(method_family = none)]
869        fn collectionView_contextMenuConfigurationForItemAtIndexPath_point(
870            &self,
871            collection_view: &UICollectionView,
872            index_path: &NSIndexPath,
873            point: CGPoint,
874        ) -> Option<Retained<UIContextMenuConfiguration>>;
875
876        #[cfg(all(
877            feature = "UIContextMenuConfiguration",
878            feature = "UIResponder",
879            feature = "UITargetedPreview",
880            feature = "UIView"
881        ))]
882        /// Called when the interaction begins. Return a UITargetedPreview describing the desired highlight preview.
883        /// If the non-deprecated replacement for the configuration, highlight preview, or dismissal preview methods is implemented this method is not called.
884        ///
885        ///
886        /// Parameter `collectionView`: The
887        /// `UICollectionView.`
888        /// Parameter `configuration`: The configuration of the menu about to be displayed by this interaction.
889        #[deprecated]
890        #[optional]
891        #[unsafe(method(collectionView:previewForHighlightingContextMenuWithConfiguration:))]
892        #[unsafe(method_family = none)]
893        fn collectionView_previewForHighlightingContextMenuWithConfiguration(
894            &self,
895            collection_view: &UICollectionView,
896            configuration: &UIContextMenuConfiguration,
897        ) -> Option<Retained<UITargetedPreview>>;
898
899        #[cfg(all(
900            feature = "UIContextMenuConfiguration",
901            feature = "UIResponder",
902            feature = "UITargetedPreview",
903            feature = "UIView"
904        ))]
905        /// Called when the interaction is about to dismiss. Return a UITargetedPreview describing the desired dismissal target.
906        /// The interaction will animate the presented menu to the target. Use this to customize the dismissal animation.
907        /// If the non-deprecated replacement for the configuration, highlight preview, or dismissal preview methods is implemented this method is not called.
908        ///
909        ///
910        /// Parameter `collectionView`: The
911        /// `UICollectionView.`
912        /// Parameter `configuration`: The configuration of the menu displayed by this interaction.
913        #[deprecated]
914        #[optional]
915        #[unsafe(method(collectionView:previewForDismissingContextMenuWithConfiguration:))]
916        #[unsafe(method_family = none)]
917        fn collectionView_previewForDismissingContextMenuWithConfiguration(
918            &self,
919            collection_view: &UICollectionView,
920            configuration: &UIContextMenuConfiguration,
921        ) -> Option<Retained<UITargetedPreview>>;
922    }
923);
924
925extern_class!(
926    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uicollectionview?language=objc)
927    #[unsafe(super(UIScrollView, UIView, UIResponder, NSObject))]
928    #[thread_kind = MainThreadOnly]
929    #[derive(Debug, PartialEq, Eq, Hash)]
930    #[cfg(all(feature = "UIResponder", feature = "UIScrollView", feature = "UIView"))]
931    pub struct UICollectionView;
932);
933
934#[cfg(all(
935    feature = "UIResponder",
936    feature = "UIScrollView",
937    feature = "UIView",
938    feature = "objc2-quartz-core"
939))]
940#[cfg(not(target_os = "watchos"))]
941extern_conformance!(
942    unsafe impl CALayerDelegate for UICollectionView {}
943);
944
945#[cfg(all(feature = "UIResponder", feature = "UIScrollView", feature = "UIView"))]
946extern_conformance!(
947    unsafe impl NSCoding for UICollectionView {}
948);
949
950#[cfg(all(feature = "UIResponder", feature = "UIScrollView", feature = "UIView"))]
951extern_conformance!(
952    unsafe impl NSObjectProtocol for UICollectionView {}
953);
954
955#[cfg(all(
956    feature = "UIAppearance",
957    feature = "UIResponder",
958    feature = "UIScrollView",
959    feature = "UIView"
960))]
961extern_conformance!(
962    unsafe impl UIAppearance for UICollectionView {}
963);
964
965#[cfg(all(
966    feature = "UIAppearance",
967    feature = "UIResponder",
968    feature = "UIScrollView",
969    feature = "UIView"
970))]
971extern_conformance!(
972    unsafe impl UIAppearanceContainer for UICollectionView {}
973);
974
975#[cfg(all(feature = "UIResponder", feature = "UIScrollView", feature = "UIView"))]
976extern_conformance!(
977    unsafe impl UICoordinateSpace for UICollectionView {}
978);
979
980#[cfg(all(
981    feature = "UIDataSourceTranslating",
982    feature = "UIResponder",
983    feature = "UIScrollView",
984    feature = "UIView"
985))]
986extern_conformance!(
987    unsafe impl UIDataSourceTranslating for UICollectionView {}
988);
989
990#[cfg(all(
991    feature = "UIDynamicBehavior",
992    feature = "UIResponder",
993    feature = "UIScrollView",
994    feature = "UIView"
995))]
996extern_conformance!(
997    unsafe impl UIDynamicItem for UICollectionView {}
998);
999
1000#[cfg(all(
1001    feature = "UIFocus",
1002    feature = "UIResponder",
1003    feature = "UIScrollView",
1004    feature = "UIView"
1005))]
1006extern_conformance!(
1007    unsafe impl UIFocusEnvironment for UICollectionView {}
1008);
1009
1010#[cfg(all(
1011    feature = "UIFocus",
1012    feature = "UIResponder",
1013    feature = "UIScrollView",
1014    feature = "UIView"
1015))]
1016extern_conformance!(
1017    unsafe impl UIFocusItem for UICollectionView {}
1018);
1019
1020#[cfg(all(
1021    feature = "UIFocus",
1022    feature = "UIResponder",
1023    feature = "UIScrollView",
1024    feature = "UIView"
1025))]
1026extern_conformance!(
1027    unsafe impl UIFocusItemContainer for UICollectionView {}
1028);
1029
1030#[cfg(all(
1031    feature = "UIFocus",
1032    feature = "UIResponder",
1033    feature = "UIScrollView",
1034    feature = "UIView"
1035))]
1036extern_conformance!(
1037    unsafe impl UIFocusItemScrollableContainer for UICollectionView {}
1038);
1039
1040#[cfg(all(feature = "UIResponder", feature = "UIScrollView", feature = "UIView"))]
1041extern_conformance!(
1042    unsafe impl UIResponderStandardEditActions for UICollectionView {}
1043);
1044
1045#[cfg(all(
1046    feature = "UIResponder",
1047    feature = "UIScrollView",
1048    feature = "UITraitCollection",
1049    feature = "UIView"
1050))]
1051extern_conformance!(
1052    unsafe impl UITraitEnvironment for UICollectionView {}
1053);
1054
1055#[cfg(all(feature = "UIResponder", feature = "UIScrollView", feature = "UIView"))]
1056impl UICollectionView {
1057    extern_methods!(
1058        #[cfg(all(feature = "UICollectionViewLayout", feature = "objc2-core-foundation"))]
1059        #[unsafe(method(initWithFrame:collectionViewLayout:))]
1060        #[unsafe(method_family = init)]
1061        pub fn initWithFrame_collectionViewLayout(
1062            this: Allocated<Self>,
1063            frame: CGRect,
1064            layout: &UICollectionViewLayout,
1065        ) -> Retained<Self>;
1066
1067        /// # Safety
1068        ///
1069        /// `coder` possibly has further requirements.
1070        #[unsafe(method(initWithCoder:))]
1071        #[unsafe(method_family = init)]
1072        pub unsafe fn initWithCoder(
1073            this: Allocated<Self>,
1074            coder: &NSCoder,
1075        ) -> Option<Retained<Self>>;
1076
1077        #[cfg(feature = "UICollectionViewLayout")]
1078        #[unsafe(method(collectionViewLayout))]
1079        #[unsafe(method_family = none)]
1080        pub fn collectionViewLayout(&self) -> Retained<UICollectionViewLayout>;
1081
1082        #[cfg(feature = "UICollectionViewLayout")]
1083        /// Setter for [`collectionViewLayout`][Self::collectionViewLayout].
1084        #[unsafe(method(setCollectionViewLayout:))]
1085        #[unsafe(method_family = none)]
1086        pub fn setCollectionViewLayout(&self, collection_view_layout: &UICollectionViewLayout);
1087
1088        #[unsafe(method(delegate))]
1089        #[unsafe(method_family = none)]
1090        pub fn delegate(&self) -> Option<Retained<ProtocolObject<dyn UICollectionViewDelegate>>>;
1091
1092        /// Setter for [`delegate`][Self::delegate].
1093        ///
1094        /// This is a [weak property][objc2::topics::weak_property].
1095        #[unsafe(method(setDelegate:))]
1096        #[unsafe(method_family = none)]
1097        pub unsafe fn setDelegate(
1098            &self,
1099            delegate: Option<&ProtocolObject<dyn UICollectionViewDelegate>>,
1100        );
1101
1102        #[unsafe(method(dataSource))]
1103        #[unsafe(method_family = none)]
1104        pub fn dataSource(
1105            &self,
1106        ) -> Option<Retained<ProtocolObject<dyn UICollectionViewDataSource>>>;
1107
1108        /// Setter for [`dataSource`][Self::dataSource].
1109        ///
1110        /// This is a [weak property][objc2::topics::weak_property].
1111        #[unsafe(method(setDataSource:))]
1112        #[unsafe(method_family = none)]
1113        pub fn setDataSource(
1114            &self,
1115            data_source: Option<&ProtocolObject<dyn UICollectionViewDataSource>>,
1116        );
1117
1118        #[unsafe(method(prefetchDataSource))]
1119        #[unsafe(method_family = none)]
1120        pub fn prefetchDataSource(
1121            &self,
1122        ) -> Option<Retained<ProtocolObject<dyn UICollectionViewDataSourcePrefetching>>>;
1123
1124        /// Setter for [`prefetchDataSource`][Self::prefetchDataSource].
1125        ///
1126        /// This is a [weak property][objc2::topics::weak_property].
1127        #[unsafe(method(setPrefetchDataSource:))]
1128        #[unsafe(method_family = none)]
1129        pub fn setPrefetchDataSource(
1130            &self,
1131            prefetch_data_source: Option<
1132                &ProtocolObject<dyn UICollectionViewDataSourcePrefetching>,
1133            >,
1134        );
1135
1136        #[unsafe(method(isPrefetchingEnabled))]
1137        #[unsafe(method_family = none)]
1138        pub fn isPrefetchingEnabled(&self) -> bool;
1139
1140        /// Setter for [`isPrefetchingEnabled`][Self::isPrefetchingEnabled].
1141        #[unsafe(method(setPrefetchingEnabled:))]
1142        #[unsafe(method_family = none)]
1143        pub fn setPrefetchingEnabled(&self, prefetching_enabled: bool);
1144
1145        #[unsafe(method(dragDelegate))]
1146        #[unsafe(method_family = none)]
1147        pub fn dragDelegate(
1148            &self,
1149        ) -> Option<Retained<ProtocolObject<dyn UICollectionViewDragDelegate>>>;
1150
1151        /// Setter for [`dragDelegate`][Self::dragDelegate].
1152        ///
1153        /// This is a [weak property][objc2::topics::weak_property].
1154        #[unsafe(method(setDragDelegate:))]
1155        #[unsafe(method_family = none)]
1156        pub fn setDragDelegate(
1157            &self,
1158            drag_delegate: Option<&ProtocolObject<dyn UICollectionViewDragDelegate>>,
1159        );
1160
1161        #[unsafe(method(dropDelegate))]
1162        #[unsafe(method_family = none)]
1163        pub fn dropDelegate(
1164            &self,
1165        ) -> Option<Retained<ProtocolObject<dyn UICollectionViewDropDelegate>>>;
1166
1167        /// Setter for [`dropDelegate`][Self::dropDelegate].
1168        ///
1169        /// This is a [weak property][objc2::topics::weak_property].
1170        #[unsafe(method(setDropDelegate:))]
1171        #[unsafe(method_family = none)]
1172        pub fn setDropDelegate(
1173            &self,
1174            drop_delegate: Option<&ProtocolObject<dyn UICollectionViewDropDelegate>>,
1175        );
1176
1177        #[unsafe(method(dragInteractionEnabled))]
1178        #[unsafe(method_family = none)]
1179        pub fn dragInteractionEnabled(&self) -> bool;
1180
1181        /// Setter for [`dragInteractionEnabled`][Self::dragInteractionEnabled].
1182        #[unsafe(method(setDragInteractionEnabled:))]
1183        #[unsafe(method_family = none)]
1184        pub fn setDragInteractionEnabled(&self, drag_interaction_enabled: bool);
1185
1186        #[cfg(feature = "UIContextMenuInteraction")]
1187        #[unsafe(method(contextMenuInteraction))]
1188        #[unsafe(method_family = none)]
1189        pub fn contextMenuInteraction(&self) -> Option<Retained<UIContextMenuInteraction>>;
1190
1191        #[unsafe(method(reorderingCadence))]
1192        #[unsafe(method_family = none)]
1193        pub fn reorderingCadence(&self) -> UICollectionViewReorderingCadence;
1194
1195        /// Setter for [`reorderingCadence`][Self::reorderingCadence].
1196        #[unsafe(method(setReorderingCadence:))]
1197        #[unsafe(method_family = none)]
1198        pub fn setReorderingCadence(&self, reordering_cadence: UICollectionViewReorderingCadence);
1199
1200        #[unsafe(method(selfSizingInvalidation))]
1201        #[unsafe(method_family = none)]
1202        pub fn selfSizingInvalidation(&self) -> UICollectionViewSelfSizingInvalidation;
1203
1204        /// Setter for [`selfSizingInvalidation`][Self::selfSizingInvalidation].
1205        #[unsafe(method(setSelfSizingInvalidation:))]
1206        #[unsafe(method_family = none)]
1207        pub fn setSelfSizingInvalidation(
1208            &self,
1209            self_sizing_invalidation: UICollectionViewSelfSizingInvalidation,
1210        );
1211
1212        #[unsafe(method(backgroundView))]
1213        #[unsafe(method_family = none)]
1214        pub fn backgroundView(&self) -> Option<Retained<UIView>>;
1215
1216        /// Setter for [`backgroundView`][Self::backgroundView].
1217        #[unsafe(method(setBackgroundView:))]
1218        #[unsafe(method_family = none)]
1219        pub fn setBackgroundView(&self, background_view: Option<&UIView>);
1220
1221        /// # Safety
1222        ///
1223        /// `cell_class` probably has further requirements.
1224        #[unsafe(method(registerClass:forCellWithReuseIdentifier:))]
1225        #[unsafe(method_family = none)]
1226        pub unsafe fn registerClass_forCellWithReuseIdentifier(
1227            &self,
1228            cell_class: Option<&AnyClass>,
1229            identifier: &NSString,
1230        );
1231
1232        #[cfg(feature = "UINib")]
1233        #[deprecated = "Loading Interface Builder products will not be supported in a future version of visionOS."]
1234        #[unsafe(method(registerNib:forCellWithReuseIdentifier:))]
1235        #[unsafe(method_family = none)]
1236        pub fn registerNib_forCellWithReuseIdentifier(
1237            &self,
1238            nib: Option<&UINib>,
1239            identifier: &NSString,
1240        );
1241
1242        /// # Safety
1243        ///
1244        /// `view_class` probably has further requirements.
1245        #[unsafe(method(registerClass:forSupplementaryViewOfKind:withReuseIdentifier:))]
1246        #[unsafe(method_family = none)]
1247        pub unsafe fn registerClass_forSupplementaryViewOfKind_withReuseIdentifier(
1248            &self,
1249            view_class: Option<&AnyClass>,
1250            element_kind: &NSString,
1251            identifier: &NSString,
1252        );
1253
1254        #[cfg(feature = "UINib")]
1255        #[deprecated = "Loading Interface Builder products will not be supported in a future version of visionOS."]
1256        #[unsafe(method(registerNib:forSupplementaryViewOfKind:withReuseIdentifier:))]
1257        #[unsafe(method_family = none)]
1258        pub fn registerNib_forSupplementaryViewOfKind_withReuseIdentifier(
1259            &self,
1260            nib: Option<&UINib>,
1261            kind: &NSString,
1262            identifier: &NSString,
1263        );
1264
1265        #[cfg(feature = "UICollectionViewCell")]
1266        #[unsafe(method(dequeueReusableCellWithReuseIdentifier:forIndexPath:))]
1267        #[unsafe(method_family = none)]
1268        pub fn dequeueReusableCellWithReuseIdentifier_forIndexPath(
1269            &self,
1270            identifier: &NSString,
1271            index_path: &NSIndexPath,
1272        ) -> Retained<UICollectionViewCell>;
1273
1274        #[cfg(feature = "UICollectionViewCell")]
1275        #[unsafe(method(dequeueReusableSupplementaryViewOfKind:withReuseIdentifier:forIndexPath:))]
1276        #[unsafe(method_family = none)]
1277        pub fn dequeueReusableSupplementaryViewOfKind_withReuseIdentifier_forIndexPath(
1278            &self,
1279            element_kind: &NSString,
1280            identifier: &NSString,
1281            index_path: &NSIndexPath,
1282        ) -> Retained<UICollectionReusableView>;
1283
1284        #[cfg(all(
1285            feature = "UICollectionViewCell",
1286            feature = "UICollectionViewItemRegistration"
1287        ))]
1288        /// # Safety
1289        ///
1290        /// `item` should be of the correct type.
1291        #[unsafe(method(dequeueConfiguredReusableCellWithRegistration:forIndexPath:item:))]
1292        #[unsafe(method_family = none)]
1293        pub unsafe fn dequeueConfiguredReusableCellWithRegistration_forIndexPath_item(
1294            &self,
1295            registration: &UICollectionViewCellRegistration,
1296            index_path: &NSIndexPath,
1297            item: &AnyObject,
1298        ) -> Retained<UICollectionViewCell>;
1299
1300        #[cfg(all(
1301            feature = "UICollectionViewCell",
1302            feature = "UICollectionViewItemRegistration"
1303        ))]
1304        #[unsafe(method(dequeueConfiguredReusableSupplementaryViewWithRegistration:forIndexPath:))]
1305        #[unsafe(method_family = none)]
1306        pub fn dequeueConfiguredReusableSupplementaryViewWithRegistration_forIndexPath(
1307            &self,
1308            registration: &UICollectionViewSupplementaryRegistration,
1309            index_path: &NSIndexPath,
1310        ) -> Retained<UICollectionReusableView>;
1311
1312        #[unsafe(method(allowsSelection))]
1313        #[unsafe(method_family = none)]
1314        pub fn allowsSelection(&self) -> bool;
1315
1316        /// Setter for [`allowsSelection`][Self::allowsSelection].
1317        #[unsafe(method(setAllowsSelection:))]
1318        #[unsafe(method_family = none)]
1319        pub fn setAllowsSelection(&self, allows_selection: bool);
1320
1321        #[unsafe(method(allowsMultipleSelection))]
1322        #[unsafe(method_family = none)]
1323        pub fn allowsMultipleSelection(&self) -> bool;
1324
1325        /// Setter for [`allowsMultipleSelection`][Self::allowsMultipleSelection].
1326        #[unsafe(method(setAllowsMultipleSelection:))]
1327        #[unsafe(method_family = none)]
1328        pub fn setAllowsMultipleSelection(&self, allows_multiple_selection: bool);
1329
1330        #[unsafe(method(indexPathsForSelectedItems))]
1331        #[unsafe(method_family = none)]
1332        pub fn indexPathsForSelectedItems(&self) -> Option<Retained<NSArray<NSIndexPath>>>;
1333
1334        #[unsafe(method(selectItemAtIndexPath:animated:scrollPosition:))]
1335        #[unsafe(method_family = none)]
1336        pub fn selectItemAtIndexPath_animated_scrollPosition(
1337            &self,
1338            index_path: Option<&NSIndexPath>,
1339            animated: bool,
1340            scroll_position: UICollectionViewScrollPosition,
1341        );
1342
1343        #[unsafe(method(deselectItemAtIndexPath:animated:))]
1344        #[unsafe(method_family = none)]
1345        pub fn deselectItemAtIndexPath_animated(&self, index_path: &NSIndexPath, animated: bool);
1346
1347        #[unsafe(method(hasUncommittedUpdates))]
1348        #[unsafe(method_family = none)]
1349        pub fn hasUncommittedUpdates(&self) -> bool;
1350
1351        #[unsafe(method(reloadData))]
1352        #[unsafe(method_family = none)]
1353        pub fn reloadData(&self);
1354
1355        #[cfg(feature = "UICollectionViewLayout")]
1356        #[unsafe(method(setCollectionViewLayout:animated:))]
1357        #[unsafe(method_family = none)]
1358        pub fn setCollectionViewLayout_animated(
1359            &self,
1360            layout: &UICollectionViewLayout,
1361            animated: bool,
1362        );
1363
1364        #[cfg(all(feature = "UICollectionViewLayout", feature = "block2"))]
1365        #[unsafe(method(setCollectionViewLayout:animated:completion:))]
1366        #[unsafe(method_family = none)]
1367        pub fn setCollectionViewLayout_animated_completion(
1368            &self,
1369            layout: &UICollectionViewLayout,
1370            animated: bool,
1371            completion: Option<&block2::DynBlock<dyn Fn(Bool)>>,
1372        );
1373
1374        #[cfg(all(
1375            feature = "UICollectionViewLayout",
1376            feature = "UICollectionViewTransitionLayout",
1377            feature = "block2"
1378        ))]
1379        /// # Safety
1380        ///
1381        /// `completion` must be a valid pointer or null.
1382        #[unsafe(method(startInteractiveTransitionToCollectionViewLayout:completion:))]
1383        #[unsafe(method_family = none)]
1384        pub unsafe fn startInteractiveTransitionToCollectionViewLayout_completion(
1385            &self,
1386            layout: &UICollectionViewLayout,
1387            completion: UICollectionViewLayoutInteractiveTransitionCompletion,
1388        ) -> Retained<UICollectionViewTransitionLayout>;
1389
1390        #[unsafe(method(finishInteractiveTransition))]
1391        #[unsafe(method_family = none)]
1392        pub fn finishInteractiveTransition(&self);
1393
1394        #[unsafe(method(cancelInteractiveTransition))]
1395        #[unsafe(method_family = none)]
1396        pub fn cancelInteractiveTransition(&self);
1397
1398        #[unsafe(method(numberOfSections))]
1399        #[unsafe(method_family = none)]
1400        pub fn numberOfSections(&self) -> NSInteger;
1401
1402        #[unsafe(method(numberOfItemsInSection:))]
1403        #[unsafe(method_family = none)]
1404        pub fn numberOfItemsInSection(&self, section: NSInteger) -> NSInteger;
1405
1406        #[cfg(feature = "UICollectionViewLayout")]
1407        #[unsafe(method(layoutAttributesForItemAtIndexPath:))]
1408        #[unsafe(method_family = none)]
1409        pub fn layoutAttributesForItemAtIndexPath(
1410            &self,
1411            index_path: &NSIndexPath,
1412        ) -> Option<Retained<UICollectionViewLayoutAttributes>>;
1413
1414        #[cfg(feature = "UICollectionViewLayout")]
1415        #[unsafe(method(layoutAttributesForSupplementaryElementOfKind:atIndexPath:))]
1416        #[unsafe(method_family = none)]
1417        pub fn layoutAttributesForSupplementaryElementOfKind_atIndexPath(
1418            &self,
1419            kind: &NSString,
1420            index_path: &NSIndexPath,
1421        ) -> Option<Retained<UICollectionViewLayoutAttributes>>;
1422
1423        #[cfg(feature = "objc2-core-foundation")]
1424        #[unsafe(method(indexPathForItemAtPoint:))]
1425        #[unsafe(method_family = none)]
1426        pub fn indexPathForItemAtPoint(&self, point: CGPoint) -> Option<Retained<NSIndexPath>>;
1427
1428        #[cfg(feature = "UICollectionViewCell")]
1429        #[unsafe(method(indexPathForCell:))]
1430        #[unsafe(method_family = none)]
1431        pub fn indexPathForCell(
1432            &self,
1433            cell: &UICollectionViewCell,
1434        ) -> Option<Retained<NSIndexPath>>;
1435
1436        #[cfg(feature = "UICollectionViewCell")]
1437        /// Gets the index path of the specified supplementary view.
1438        ///
1439        /// Parameter `supplementaryView`: The supplementary or decoration view whose index path you want.
1440        ///
1441        /// Returns: The index path of the specified view if it is in the collection view, else `nil`.
1442        #[unsafe(method(indexPathForSupplementaryView:))]
1443        #[unsafe(method_family = none)]
1444        pub fn indexPathForSupplementaryView(
1445            &self,
1446            supplementary_view: &UICollectionReusableView,
1447        ) -> Option<Retained<NSIndexPath>>;
1448
1449        #[cfg(feature = "UICollectionViewCell")]
1450        #[unsafe(method(cellForItemAtIndexPath:))]
1451        #[unsafe(method_family = none)]
1452        pub fn cellForItemAtIndexPath(
1453            &self,
1454            index_path: &NSIndexPath,
1455        ) -> Option<Retained<UICollectionViewCell>>;
1456
1457        #[cfg(feature = "UICollectionViewCell")]
1458        #[unsafe(method(visibleCells))]
1459        #[unsafe(method_family = none)]
1460        pub fn visibleCells(&self) -> Retained<NSArray<UICollectionViewCell>>;
1461
1462        #[unsafe(method(indexPathsForVisibleItems))]
1463        #[unsafe(method_family = none)]
1464        pub fn indexPathsForVisibleItems(&self) -> Retained<NSArray<NSIndexPath>>;
1465
1466        #[cfg(feature = "UICollectionViewCell")]
1467        #[unsafe(method(supplementaryViewForElementKind:atIndexPath:))]
1468        #[unsafe(method_family = none)]
1469        pub fn supplementaryViewForElementKind_atIndexPath(
1470            &self,
1471            element_kind: &NSString,
1472            index_path: &NSIndexPath,
1473        ) -> Option<Retained<UICollectionReusableView>>;
1474
1475        #[cfg(feature = "UICollectionViewCell")]
1476        #[unsafe(method(visibleSupplementaryViewsOfKind:))]
1477        #[unsafe(method_family = none)]
1478        pub fn visibleSupplementaryViewsOfKind(
1479            &self,
1480            element_kind: &NSString,
1481        ) -> Retained<NSArray<UICollectionReusableView>>;
1482
1483        #[unsafe(method(indexPathsForVisibleSupplementaryElementsOfKind:))]
1484        #[unsafe(method_family = none)]
1485        pub fn indexPathsForVisibleSupplementaryElementsOfKind(
1486            &self,
1487            element_kind: &NSString,
1488        ) -> Retained<NSArray<NSIndexPath>>;
1489
1490        #[unsafe(method(scrollToItemAtIndexPath:atScrollPosition:animated:))]
1491        #[unsafe(method_family = none)]
1492        pub fn scrollToItemAtIndexPath_atScrollPosition_animated(
1493            &self,
1494            index_path: &NSIndexPath,
1495            scroll_position: UICollectionViewScrollPosition,
1496            animated: bool,
1497        );
1498
1499        #[unsafe(method(insertSections:))]
1500        #[unsafe(method_family = none)]
1501        pub fn insertSections(&self, sections: &NSIndexSet);
1502
1503        #[unsafe(method(deleteSections:))]
1504        #[unsafe(method_family = none)]
1505        pub fn deleteSections(&self, sections: &NSIndexSet);
1506
1507        #[unsafe(method(moveSection:toSection:))]
1508        #[unsafe(method_family = none)]
1509        pub fn moveSection_toSection(&self, section: NSInteger, new_section: NSInteger);
1510
1511        #[unsafe(method(reloadSections:))]
1512        #[unsafe(method_family = none)]
1513        pub fn reloadSections(&self, sections: &NSIndexSet);
1514
1515        #[unsafe(method(insertItemsAtIndexPaths:))]
1516        #[unsafe(method_family = none)]
1517        pub fn insertItemsAtIndexPaths(&self, index_paths: &NSArray<NSIndexPath>);
1518
1519        #[unsafe(method(deleteItemsAtIndexPaths:))]
1520        #[unsafe(method_family = none)]
1521        pub fn deleteItemsAtIndexPaths(&self, index_paths: &NSArray<NSIndexPath>);
1522
1523        #[unsafe(method(moveItemAtIndexPath:toIndexPath:))]
1524        #[unsafe(method_family = none)]
1525        pub fn moveItemAtIndexPath_toIndexPath(
1526            &self,
1527            index_path: &NSIndexPath,
1528            new_index_path: &NSIndexPath,
1529        );
1530
1531        #[unsafe(method(reloadItemsAtIndexPaths:))]
1532        #[unsafe(method_family = none)]
1533        pub fn reloadItemsAtIndexPaths(&self, index_paths: &NSArray<NSIndexPath>);
1534
1535        #[unsafe(method(reconfigureItemsAtIndexPaths:))]
1536        #[unsafe(method_family = none)]
1537        pub fn reconfigureItemsAtIndexPaths(&self, index_paths: &NSArray<NSIndexPath>);
1538
1539        #[cfg(feature = "block2")]
1540        #[unsafe(method(performBatchUpdates:completion:))]
1541        #[unsafe(method_family = none)]
1542        pub fn performBatchUpdates_completion(
1543            &self,
1544            updates: Option<&block2::DynBlock<dyn Fn() + '_>>,
1545            completion: Option<&block2::DynBlock<dyn Fn(Bool)>>,
1546        );
1547
1548        #[unsafe(method(beginInteractiveMovementForItemAtIndexPath:))]
1549        #[unsafe(method_family = none)]
1550        pub fn beginInteractiveMovementForItemAtIndexPath(&self, index_path: &NSIndexPath) -> bool;
1551
1552        #[cfg(feature = "objc2-core-foundation")]
1553        #[unsafe(method(updateInteractiveMovementTargetPosition:))]
1554        #[unsafe(method_family = none)]
1555        pub fn updateInteractiveMovementTargetPosition(&self, target_position: CGPoint);
1556
1557        #[unsafe(method(endInteractiveMovement))]
1558        #[unsafe(method_family = none)]
1559        pub fn endInteractiveMovement(&self);
1560
1561        #[unsafe(method(cancelInteractiveMovement))]
1562        #[unsafe(method_family = none)]
1563        pub fn cancelInteractiveMovement(&self);
1564
1565        #[unsafe(method(remembersLastFocusedIndexPath))]
1566        #[unsafe(method_family = none)]
1567        pub fn remembersLastFocusedIndexPath(&self) -> bool;
1568
1569        /// Setter for [`remembersLastFocusedIndexPath`][Self::remembersLastFocusedIndexPath].
1570        #[unsafe(method(setRemembersLastFocusedIndexPath:))]
1571        #[unsafe(method_family = none)]
1572        pub fn setRemembersLastFocusedIndexPath(&self, remembers_last_focused_index_path: bool);
1573
1574        /// When enabled, the collection view ensures that selection is automatically triggered when focus moves to a cell.
1575        /// Defaults to a system derived value based on platform and other properties of the collection view.
1576        #[unsafe(method(selectionFollowsFocus))]
1577        #[unsafe(method_family = none)]
1578        pub fn selectionFollowsFocus(&self) -> bool;
1579
1580        /// Setter for [`selectionFollowsFocus`][Self::selectionFollowsFocus].
1581        #[unsafe(method(setSelectionFollowsFocus:))]
1582        #[unsafe(method_family = none)]
1583        pub fn setSelectionFollowsFocus(&self, selection_follows_focus: bool);
1584
1585        /// Determines if the collection view allows its cells to become focused.
1586        /// When collectionView:canFocusItemAtIndexPath: is implemented, its return value takes precedence over this method.
1587        /// Defaults to a system derived value based on platform and other properties of the collection view.
1588        #[unsafe(method(allowsFocus))]
1589        #[unsafe(method_family = none)]
1590        pub fn allowsFocus(&self) -> bool;
1591
1592        /// Setter for [`allowsFocus`][Self::allowsFocus].
1593        #[unsafe(method(setAllowsFocus:))]
1594        #[unsafe(method_family = none)]
1595        pub fn setAllowsFocus(&self, allows_focus: bool);
1596
1597        /// Determines if the collection view allows its cells to become focused while editing.
1598        /// When collectionView:canFocusItemAtIndexPath: is implemented, its return value takes precedence over this method.
1599        /// Defaults to a system derived value based on platform and other properties of the collection view.
1600        #[unsafe(method(allowsFocusDuringEditing))]
1601        #[unsafe(method_family = none)]
1602        pub fn allowsFocusDuringEditing(&self) -> bool;
1603
1604        /// Setter for [`allowsFocusDuringEditing`][Self::allowsFocusDuringEditing].
1605        #[unsafe(method(setAllowsFocusDuringEditing:))]
1606        #[unsafe(method_family = none)]
1607        pub fn setAllowsFocusDuringEditing(&self, allows_focus_during_editing: bool);
1608
1609        #[unsafe(method(hasActiveDrag))]
1610        #[unsafe(method_family = none)]
1611        pub fn hasActiveDrag(&self) -> bool;
1612
1613        #[unsafe(method(hasActiveDrop))]
1614        #[unsafe(method_family = none)]
1615        pub fn hasActiveDrop(&self) -> bool;
1616
1617        #[unsafe(method(isEditing))]
1618        #[unsafe(method_family = none)]
1619        pub fn isEditing(&self) -> bool;
1620
1621        /// Setter for [`isEditing`][Self::isEditing].
1622        #[unsafe(method(setEditing:))]
1623        #[unsafe(method_family = none)]
1624        pub fn setEditing(&self, editing: bool);
1625
1626        #[unsafe(method(allowsSelectionDuringEditing))]
1627        #[unsafe(method_family = none)]
1628        pub fn allowsSelectionDuringEditing(&self) -> bool;
1629
1630        /// Setter for [`allowsSelectionDuringEditing`][Self::allowsSelectionDuringEditing].
1631        #[unsafe(method(setAllowsSelectionDuringEditing:))]
1632        #[unsafe(method_family = none)]
1633        pub fn setAllowsSelectionDuringEditing(&self, allows_selection_during_editing: bool);
1634
1635        #[unsafe(method(allowsMultipleSelectionDuringEditing))]
1636        #[unsafe(method_family = none)]
1637        pub fn allowsMultipleSelectionDuringEditing(&self) -> bool;
1638
1639        /// Setter for [`allowsMultipleSelectionDuringEditing`][Self::allowsMultipleSelectionDuringEditing].
1640        #[unsafe(method(setAllowsMultipleSelectionDuringEditing:))]
1641        #[unsafe(method_family = none)]
1642        pub fn setAllowsMultipleSelectionDuringEditing(
1643            &self,
1644            allows_multiple_selection_during_editing: bool,
1645        );
1646    );
1647}
1648
1649/// Methods declared on superclass `UIView`.
1650#[cfg(all(feature = "UIResponder", feature = "UIScrollView", feature = "UIView"))]
1651impl UICollectionView {
1652    extern_methods!(
1653        #[cfg(feature = "objc2-core-foundation")]
1654        #[unsafe(method(initWithFrame:))]
1655        #[unsafe(method_family = init)]
1656        pub fn initWithFrame(this: Allocated<Self>, frame: CGRect) -> Retained<Self>;
1657
1658        #[unsafe(method(init))]
1659        #[unsafe(method_family = init)]
1660        pub fn init(this: Allocated<Self>) -> Retained<Self>;
1661    );
1662}
1663
1664/// Methods declared on superclass `NSObject`.
1665#[cfg(all(feature = "UIResponder", feature = "UIScrollView", feature = "UIView"))]
1666impl UICollectionView {
1667    extern_methods!(
1668        #[unsafe(method(new))]
1669        #[unsafe(method_family = new)]
1670        pub fn new(mtm: MainThreadMarker) -> Retained<Self>;
1671    );
1672}
1673
1674/// UIDragAndDrop.
1675#[cfg(all(feature = "UIResponder", feature = "UIScrollView", feature = "UIView"))]
1676impl UICollectionView {
1677    extern_methods!();
1678}
1679
1680#[cfg(all(
1681    feature = "UIResponder",
1682    feature = "UIScrollView",
1683    feature = "UISpringLoadedInteractionSupporting",
1684    feature = "UIView"
1685))]
1686extern_conformance!(
1687    unsafe impl UISpringLoadedInteractionSupporting for UICollectionView {}
1688);
1689
1690extern_protocol!(
1691    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uicollectionviewdragdelegate?language=objc)
1692    pub unsafe trait UICollectionViewDragDelegate:
1693        NSObjectProtocol + MainThreadOnly
1694    {
1695        #[cfg(all(
1696            feature = "UIDragItem",
1697            feature = "UIDragSession",
1698            feature = "UIResponder",
1699            feature = "UIScrollView",
1700            feature = "UIView"
1701        ))]
1702        #[unsafe(method(collectionView:itemsForBeginningDragSession:atIndexPath:))]
1703        #[unsafe(method_family = none)]
1704        fn collectionView_itemsForBeginningDragSession_atIndexPath(
1705            &self,
1706            collection_view: &UICollectionView,
1707            session: &ProtocolObject<dyn UIDragSession>,
1708            index_path: &NSIndexPath,
1709        ) -> Retained<NSArray<UIDragItem>>;
1710
1711        #[cfg(all(
1712            feature = "UIDragItem",
1713            feature = "UIDragSession",
1714            feature = "UIResponder",
1715            feature = "UIScrollView",
1716            feature = "UIView",
1717            feature = "objc2-core-foundation"
1718        ))]
1719        #[optional]
1720        #[unsafe(method(collectionView:itemsForAddingToDragSession:atIndexPath:point:))]
1721        #[unsafe(method_family = none)]
1722        fn collectionView_itemsForAddingToDragSession_atIndexPath_point(
1723            &self,
1724            collection_view: &UICollectionView,
1725            session: &ProtocolObject<dyn UIDragSession>,
1726            index_path: &NSIndexPath,
1727            point: CGPoint,
1728        ) -> Retained<NSArray<UIDragItem>>;
1729
1730        #[cfg(all(
1731            feature = "UIDragPreviewParameters",
1732            feature = "UIPreviewParameters",
1733            feature = "UIResponder",
1734            feature = "UIScrollView",
1735            feature = "UIView"
1736        ))]
1737        #[optional]
1738        #[unsafe(method(collectionView:dragPreviewParametersForItemAtIndexPath:))]
1739        #[unsafe(method_family = none)]
1740        fn collectionView_dragPreviewParametersForItemAtIndexPath(
1741            &self,
1742            collection_view: &UICollectionView,
1743            index_path: &NSIndexPath,
1744        ) -> Option<Retained<UIDragPreviewParameters>>;
1745
1746        #[cfg(all(
1747            feature = "UIDragSession",
1748            feature = "UIResponder",
1749            feature = "UIScrollView",
1750            feature = "UIView"
1751        ))]
1752        #[optional]
1753        #[unsafe(method(collectionView:dragSessionWillBegin:))]
1754        #[unsafe(method_family = none)]
1755        fn collectionView_dragSessionWillBegin(
1756            &self,
1757            collection_view: &UICollectionView,
1758            session: &ProtocolObject<dyn UIDragSession>,
1759        );
1760
1761        #[cfg(all(
1762            feature = "UIDragSession",
1763            feature = "UIResponder",
1764            feature = "UIScrollView",
1765            feature = "UIView"
1766        ))]
1767        #[optional]
1768        #[unsafe(method(collectionView:dragSessionDidEnd:))]
1769        #[unsafe(method_family = none)]
1770        fn collectionView_dragSessionDidEnd(
1771            &self,
1772            collection_view: &UICollectionView,
1773            session: &ProtocolObject<dyn UIDragSession>,
1774        );
1775
1776        #[cfg(all(
1777            feature = "UIDragSession",
1778            feature = "UIResponder",
1779            feature = "UIScrollView",
1780            feature = "UIView"
1781        ))]
1782        #[optional]
1783        #[unsafe(method(collectionView:dragSessionAllowsMoveOperation:))]
1784        #[unsafe(method_family = none)]
1785        fn collectionView_dragSessionAllowsMoveOperation(
1786            &self,
1787            collection_view: &UICollectionView,
1788            session: &ProtocolObject<dyn UIDragSession>,
1789        ) -> bool;
1790
1791        #[cfg(all(
1792            feature = "UIDragSession",
1793            feature = "UIResponder",
1794            feature = "UIScrollView",
1795            feature = "UIView"
1796        ))]
1797        #[optional]
1798        #[unsafe(method(collectionView:dragSessionIsRestrictedToDraggingApplication:))]
1799        #[unsafe(method_family = none)]
1800        fn collectionView_dragSessionIsRestrictedToDraggingApplication(
1801            &self,
1802            collection_view: &UICollectionView,
1803            session: &ProtocolObject<dyn UIDragSession>,
1804        ) -> bool;
1805    }
1806);
1807
1808extern_protocol!(
1809    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uicollectionviewdropdelegate?language=objc)
1810    pub unsafe trait UICollectionViewDropDelegate:
1811        NSObjectProtocol + MainThreadOnly
1812    {
1813        #[cfg(all(feature = "UIResponder", feature = "UIScrollView", feature = "UIView"))]
1814        #[unsafe(method(collectionView:performDropWithCoordinator:))]
1815        #[unsafe(method_family = none)]
1816        fn collectionView_performDropWithCoordinator(
1817            &self,
1818            collection_view: &UICollectionView,
1819            coordinator: &ProtocolObject<dyn UICollectionViewDropCoordinator>,
1820        );
1821
1822        #[cfg(all(
1823            feature = "UIDragSession",
1824            feature = "UIResponder",
1825            feature = "UIScrollView",
1826            feature = "UIView"
1827        ))]
1828        #[optional]
1829        #[unsafe(method(collectionView:canHandleDropSession:))]
1830        #[unsafe(method_family = none)]
1831        fn collectionView_canHandleDropSession(
1832            &self,
1833            collection_view: &UICollectionView,
1834            session: &ProtocolObject<dyn UIDropSession>,
1835        ) -> bool;
1836
1837        #[cfg(all(
1838            feature = "UIDragSession",
1839            feature = "UIResponder",
1840            feature = "UIScrollView",
1841            feature = "UIView"
1842        ))]
1843        #[optional]
1844        #[unsafe(method(collectionView:dropSessionDidEnter:))]
1845        #[unsafe(method_family = none)]
1846        fn collectionView_dropSessionDidEnter(
1847            &self,
1848            collection_view: &UICollectionView,
1849            session: &ProtocolObject<dyn UIDropSession>,
1850        );
1851
1852        #[cfg(all(
1853            feature = "UIDragSession",
1854            feature = "UIDropInteraction",
1855            feature = "UIResponder",
1856            feature = "UIScrollView",
1857            feature = "UIView"
1858        ))]
1859        #[optional]
1860        #[unsafe(method(collectionView:dropSessionDidUpdate:withDestinationIndexPath:))]
1861        #[unsafe(method_family = none)]
1862        fn collectionView_dropSessionDidUpdate_withDestinationIndexPath(
1863            &self,
1864            collection_view: &UICollectionView,
1865            session: &ProtocolObject<dyn UIDropSession>,
1866            destination_index_path: Option<&NSIndexPath>,
1867        ) -> Retained<UICollectionViewDropProposal>;
1868
1869        #[cfg(all(
1870            feature = "UIDragSession",
1871            feature = "UIResponder",
1872            feature = "UIScrollView",
1873            feature = "UIView"
1874        ))]
1875        #[optional]
1876        #[unsafe(method(collectionView:dropSessionDidExit:))]
1877        #[unsafe(method_family = none)]
1878        fn collectionView_dropSessionDidExit(
1879            &self,
1880            collection_view: &UICollectionView,
1881            session: &ProtocolObject<dyn UIDropSession>,
1882        );
1883
1884        #[cfg(all(
1885            feature = "UIDragSession",
1886            feature = "UIResponder",
1887            feature = "UIScrollView",
1888            feature = "UIView"
1889        ))]
1890        #[optional]
1891        #[unsafe(method(collectionView:dropSessionDidEnd:))]
1892        #[unsafe(method_family = none)]
1893        fn collectionView_dropSessionDidEnd(
1894            &self,
1895            collection_view: &UICollectionView,
1896            session: &ProtocolObject<dyn UIDropSession>,
1897        );
1898
1899        #[cfg(all(
1900            feature = "UIDragPreviewParameters",
1901            feature = "UIPreviewParameters",
1902            feature = "UIResponder",
1903            feature = "UIScrollView",
1904            feature = "UIView"
1905        ))]
1906        #[optional]
1907        #[unsafe(method(collectionView:dropPreviewParametersForItemAtIndexPath:))]
1908        #[unsafe(method_family = none)]
1909        fn collectionView_dropPreviewParametersForItemAtIndexPath(
1910            &self,
1911            collection_view: &UICollectionView,
1912            index_path: &NSIndexPath,
1913        ) -> Option<Retained<UIDragPreviewParameters>>;
1914    }
1915);
1916
1917/// [Apple's documentation](https://developer.apple.com/documentation/uikit/uicollectionviewdropintent?language=objc)
1918// NS_ENUM
1919#[repr(transparent)]
1920#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
1921pub struct UICollectionViewDropIntent(pub NSInteger);
1922impl UICollectionViewDropIntent {
1923    #[doc(alias = "UICollectionViewDropIntentUnspecified")]
1924    pub const Unspecified: Self = Self(0);
1925    #[doc(alias = "UICollectionViewDropIntentInsertAtDestinationIndexPath")]
1926    pub const InsertAtDestinationIndexPath: Self = Self(1);
1927    #[doc(alias = "UICollectionViewDropIntentInsertIntoDestinationIndexPath")]
1928    pub const InsertIntoDestinationIndexPath: Self = Self(2);
1929}
1930
1931unsafe impl Encode for UICollectionViewDropIntent {
1932    const ENCODING: Encoding = NSInteger::ENCODING;
1933}
1934
1935unsafe impl RefEncode for UICollectionViewDropIntent {
1936    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
1937}
1938
1939extern_class!(
1940    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uicollectionviewdropproposal?language=objc)
1941    #[unsafe(super(UIDropProposal, NSObject))]
1942    #[thread_kind = MainThreadOnly]
1943    #[derive(Debug, PartialEq, Eq, Hash)]
1944    #[cfg(feature = "UIDropInteraction")]
1945    pub struct UICollectionViewDropProposal;
1946);
1947
1948#[cfg(feature = "UIDropInteraction")]
1949extern_conformance!(
1950    unsafe impl NSCopying for UICollectionViewDropProposal {}
1951);
1952
1953#[cfg(feature = "UIDropInteraction")]
1954unsafe impl CopyingHelper for UICollectionViewDropProposal {
1955    type Result = Self;
1956}
1957
1958#[cfg(feature = "UIDropInteraction")]
1959extern_conformance!(
1960    unsafe impl NSObjectProtocol for UICollectionViewDropProposal {}
1961);
1962
1963#[cfg(feature = "UIDropInteraction")]
1964impl UICollectionViewDropProposal {
1965    extern_methods!(
1966        #[unsafe(method(initWithDropOperation:intent:))]
1967        #[unsafe(method_family = init)]
1968        pub fn initWithDropOperation_intent(
1969            this: Allocated<Self>,
1970            operation: UIDropOperation,
1971            intent: UICollectionViewDropIntent,
1972        ) -> Retained<Self>;
1973
1974        #[unsafe(method(intent))]
1975        #[unsafe(method_family = none)]
1976        pub fn intent(&self) -> UICollectionViewDropIntent;
1977    );
1978}
1979
1980/// Methods declared on superclass `UIDropProposal`.
1981#[cfg(feature = "UIDropInteraction")]
1982impl UICollectionViewDropProposal {
1983    extern_methods!(
1984        #[unsafe(method(initWithDropOperation:))]
1985        #[unsafe(method_family = init)]
1986        pub fn initWithDropOperation(
1987            this: Allocated<Self>,
1988            operation: UIDropOperation,
1989        ) -> Retained<Self>;
1990
1991        #[unsafe(method(init))]
1992        #[unsafe(method_family = init)]
1993        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
1994
1995        #[unsafe(method(new))]
1996        #[unsafe(method_family = new)]
1997        pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
1998    );
1999}
2000
2001extern_protocol!(
2002    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uicollectionviewdropcoordinator?language=objc)
2003    pub unsafe trait UICollectionViewDropCoordinator:
2004        NSObjectProtocol + MainThreadOnly
2005    {
2006        #[unsafe(method(items))]
2007        #[unsafe(method_family = none)]
2008        fn items(&self) -> Retained<NSArray<ProtocolObject<dyn UICollectionViewDropItem>>>;
2009
2010        #[unsafe(method(destinationIndexPath))]
2011        #[unsafe(method_family = none)]
2012        fn destinationIndexPath(&self) -> Option<Retained<NSIndexPath>>;
2013
2014        #[cfg(feature = "UIDropInteraction")]
2015        #[unsafe(method(proposal))]
2016        #[unsafe(method_family = none)]
2017        fn proposal(&self) -> Retained<UICollectionViewDropProposal>;
2018
2019        #[cfg(feature = "UIDragSession")]
2020        #[unsafe(method(session))]
2021        #[unsafe(method_family = none)]
2022        fn session(&self) -> Retained<ProtocolObject<dyn UIDropSession>>;
2023
2024        #[cfg(all(feature = "UIDragInteraction", feature = "UIDragItem"))]
2025        #[unsafe(method(dropItem:toPlaceholder:))]
2026        #[unsafe(method_family = none)]
2027        fn dropItem_toPlaceholder(
2028            &self,
2029            drag_item: &UIDragItem,
2030            placeholder: &UICollectionViewDropPlaceholder,
2031        ) -> Retained<ProtocolObject<dyn UICollectionViewDropPlaceholderContext>>;
2032
2033        #[cfg(all(feature = "UIDragInteraction", feature = "UIDragItem"))]
2034        #[unsafe(method(dropItem:toItemAtIndexPath:))]
2035        #[unsafe(method_family = none)]
2036        fn dropItem_toItemAtIndexPath(
2037            &self,
2038            drag_item: &UIDragItem,
2039            index_path: &NSIndexPath,
2040        ) -> Retained<ProtocolObject<dyn UIDragAnimating>>;
2041
2042        #[cfg(all(
2043            feature = "UIDragInteraction",
2044            feature = "UIDragItem",
2045            feature = "objc2-core-foundation"
2046        ))]
2047        #[unsafe(method(dropItem:intoItemAtIndexPath:rect:))]
2048        #[unsafe(method_family = none)]
2049        fn dropItem_intoItemAtIndexPath_rect(
2050            &self,
2051            drag_item: &UIDragItem,
2052            index_path: &NSIndexPath,
2053            rect: CGRect,
2054        ) -> Retained<ProtocolObject<dyn UIDragAnimating>>;
2055
2056        #[cfg(all(
2057            feature = "UIDragInteraction",
2058            feature = "UIDragItem",
2059            feature = "UITargetedDragPreview",
2060            feature = "UITargetedPreview"
2061        ))]
2062        #[unsafe(method(dropItem:toTarget:))]
2063        #[unsafe(method_family = none)]
2064        fn dropItem_toTarget(
2065            &self,
2066            drag_item: &UIDragItem,
2067            target: &UIDragPreviewTarget,
2068        ) -> Retained<ProtocolObject<dyn UIDragAnimating>>;
2069    }
2070);
2071
2072extern_class!(
2073    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uicollectionviewplaceholder?language=objc)
2074    #[unsafe(super(NSObject))]
2075    #[thread_kind = MainThreadOnly]
2076    #[derive(Debug, PartialEq, Eq, Hash)]
2077    pub struct UICollectionViewPlaceholder;
2078);
2079
2080extern_conformance!(
2081    unsafe impl NSObjectProtocol for UICollectionViewPlaceholder {}
2082);
2083
2084impl UICollectionViewPlaceholder {
2085    extern_methods!(
2086        #[unsafe(method(initWithInsertionIndexPath:reuseIdentifier:))]
2087        #[unsafe(method_family = init)]
2088        pub fn initWithInsertionIndexPath_reuseIdentifier(
2089            this: Allocated<Self>,
2090            insertion_index_path: &NSIndexPath,
2091            reuse_identifier: &NSString,
2092        ) -> Retained<Self>;
2093
2094        #[unsafe(method(init))]
2095        #[unsafe(method_family = init)]
2096        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
2097
2098        #[unsafe(method(new))]
2099        #[unsafe(method_family = new)]
2100        pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
2101
2102        #[cfg(all(
2103            feature = "UICollectionViewCell",
2104            feature = "UIResponder",
2105            feature = "UIView",
2106            feature = "block2"
2107        ))]
2108        /// # Safety
2109        ///
2110        /// The returned block's argument must be a valid pointer.
2111        #[unsafe(method(cellUpdateHandler))]
2112        #[unsafe(method_family = none)]
2113        pub unsafe fn cellUpdateHandler(
2114            &self,
2115        ) -> *mut block2::DynBlock<dyn Fn(NonNull<UICollectionViewCell>)>;
2116
2117        #[cfg(all(
2118            feature = "UICollectionViewCell",
2119            feature = "UIResponder",
2120            feature = "UIView",
2121            feature = "block2"
2122        ))]
2123        /// Setter for [`cellUpdateHandler`][Self::cellUpdateHandler].
2124        ///
2125        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
2126        #[unsafe(method(setCellUpdateHandler:))]
2127        #[unsafe(method_family = none)]
2128        pub fn setCellUpdateHandler(
2129            &self,
2130            cell_update_handler: Option<&block2::DynBlock<dyn Fn(NonNull<UICollectionViewCell>)>>,
2131        );
2132    );
2133}
2134
2135extern_class!(
2136    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uicollectionviewdropplaceholder?language=objc)
2137    #[unsafe(super(UICollectionViewPlaceholder, NSObject))]
2138    #[thread_kind = MainThreadOnly]
2139    #[derive(Debug, PartialEq, Eq, Hash)]
2140    pub struct UICollectionViewDropPlaceholder;
2141);
2142
2143extern_conformance!(
2144    unsafe impl NSObjectProtocol for UICollectionViewDropPlaceholder {}
2145);
2146
2147impl UICollectionViewDropPlaceholder {
2148    extern_methods!(
2149        #[cfg(all(
2150            feature = "UICollectionViewCell",
2151            feature = "UIDragPreviewParameters",
2152            feature = "UIPreviewParameters",
2153            feature = "UIResponder",
2154            feature = "UIView",
2155            feature = "block2"
2156        ))]
2157        /// # Safety
2158        ///
2159        /// The returned block's argument must be a valid pointer.
2160        #[unsafe(method(previewParametersProvider))]
2161        #[unsafe(method_family = none)]
2162        pub unsafe fn previewParametersProvider(
2163            &self,
2164        ) -> *mut block2::DynBlock<
2165            dyn Fn(NonNull<UICollectionViewCell>) -> *mut UIDragPreviewParameters,
2166        >;
2167
2168        #[cfg(all(
2169            feature = "UICollectionViewCell",
2170            feature = "UIDragPreviewParameters",
2171            feature = "UIPreviewParameters",
2172            feature = "UIResponder",
2173            feature = "UIView",
2174            feature = "block2"
2175        ))]
2176        /// Setter for [`previewParametersProvider`][Self::previewParametersProvider].
2177        ///
2178        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
2179        ///
2180        /// # Safety
2181        ///
2182        /// `preview_parameters_provider` block's return must be a valid pointer or null.
2183        #[unsafe(method(setPreviewParametersProvider:))]
2184        #[unsafe(method_family = none)]
2185        pub unsafe fn setPreviewParametersProvider(
2186            &self,
2187            preview_parameters_provider: Option<
2188                &block2::DynBlock<
2189                    dyn Fn(NonNull<UICollectionViewCell>) -> *mut UIDragPreviewParameters,
2190                >,
2191            >,
2192        );
2193    );
2194}
2195
2196/// Methods declared on superclass `UICollectionViewPlaceholder`.
2197impl UICollectionViewDropPlaceholder {
2198    extern_methods!(
2199        #[unsafe(method(initWithInsertionIndexPath:reuseIdentifier:))]
2200        #[unsafe(method_family = init)]
2201        pub fn initWithInsertionIndexPath_reuseIdentifier(
2202            this: Allocated<Self>,
2203            insertion_index_path: &NSIndexPath,
2204            reuse_identifier: &NSString,
2205        ) -> Retained<Self>;
2206
2207        #[unsafe(method(init))]
2208        #[unsafe(method_family = init)]
2209        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
2210
2211        #[unsafe(method(new))]
2212        #[unsafe(method_family = new)]
2213        pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
2214    );
2215}
2216
2217extern_protocol!(
2218    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uicollectionviewdropitem?language=objc)
2219    pub unsafe trait UICollectionViewDropItem: NSObjectProtocol + MainThreadOnly {
2220        #[cfg(feature = "UIDragItem")]
2221        #[unsafe(method(dragItem))]
2222        #[unsafe(method_family = none)]
2223        fn dragItem(&self) -> Retained<UIDragItem>;
2224
2225        #[unsafe(method(sourceIndexPath))]
2226        #[unsafe(method_family = none)]
2227        fn sourceIndexPath(&self) -> Option<Retained<NSIndexPath>>;
2228
2229        #[cfg(feature = "objc2-core-foundation")]
2230        #[unsafe(method(previewSize))]
2231        #[unsafe(method_family = none)]
2232        fn previewSize(&self) -> CGSize;
2233    }
2234);
2235
2236extern_protocol!(
2237    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uicollectionviewdropplaceholdercontext?language=objc)
2238    #[cfg(feature = "UIDragInteraction")]
2239    pub unsafe trait UICollectionViewDropPlaceholderContext:
2240        UIDragAnimating + MainThreadOnly
2241    {
2242        #[cfg(feature = "UIDragItem")]
2243        #[unsafe(method(dragItem))]
2244        #[unsafe(method_family = none)]
2245        fn dragItem(&self) -> Retained<UIDragItem>;
2246
2247        #[cfg(feature = "block2")]
2248        #[unsafe(method(commitInsertionWithDataSourceUpdates:))]
2249        #[unsafe(method_family = none)]
2250        fn commitInsertionWithDataSourceUpdates(
2251            &self,
2252            data_source_updates: &block2::DynBlock<dyn Fn(NonNull<NSIndexPath>) + '_>,
2253        ) -> bool;
2254
2255        #[unsafe(method(deletePlaceholder))]
2256        #[unsafe(method_family = none)]
2257        fn deletePlaceholder(&self) -> bool;
2258
2259        #[unsafe(method(setNeedsCellUpdate))]
2260        #[unsafe(method_family = none)]
2261        fn setNeedsCellUpdate(&self);
2262    }
2263);