1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
//! This file has been automatically generated by `objc2`'s `header-translator`.
//! DO NOT EDIT
#[cfg(feature = "block2")]
use block2::*;
use objc2::__framework_prelude::*;
use objc2_foundation::*;

use crate::*;

// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct NSCollectionViewDropOperation(pub NSInteger);
impl NSCollectionViewDropOperation {
    pub const NSCollectionViewDropOn: Self = Self(0);
    pub const NSCollectionViewDropBefore: Self = Self(1);
}

unsafe impl Encode for NSCollectionViewDropOperation {
    const ENCODING: Encoding = NSInteger::ENCODING;
}

unsafe impl RefEncode for NSCollectionViewDropOperation {
    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}

// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct NSCollectionViewItemHighlightState(pub NSInteger);
impl NSCollectionViewItemHighlightState {
    pub const NSCollectionViewItemHighlightNone: Self = Self(0);
    pub const NSCollectionViewItemHighlightForSelection: Self = Self(1);
    pub const NSCollectionViewItemHighlightForDeselection: Self = Self(2);
    pub const NSCollectionViewItemHighlightAsDropTarget: Self = Self(3);
}

unsafe impl Encode for NSCollectionViewItemHighlightState {
    const ENCODING: Encoding = NSInteger::ENCODING;
}

unsafe impl RefEncode for NSCollectionViewItemHighlightState {
    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}

// NS_OPTIONS
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct NSCollectionViewScrollPosition(pub NSUInteger);
impl NSCollectionViewScrollPosition {
    #[doc(alias = "NSCollectionViewScrollPositionNone")]
    pub const None: Self = Self(0);
    #[doc(alias = "NSCollectionViewScrollPositionTop")]
    pub const Top: Self = Self(1 << 0);
    #[doc(alias = "NSCollectionViewScrollPositionCenteredVertically")]
    pub const CenteredVertically: Self = Self(1 << 1);
    #[doc(alias = "NSCollectionViewScrollPositionBottom")]
    pub const Bottom: Self = Self(1 << 2);
    #[doc(alias = "NSCollectionViewScrollPositionNearestHorizontalEdge")]
    pub const NearestHorizontalEdge: Self = Self(1 << 9);
    #[doc(alias = "NSCollectionViewScrollPositionLeft")]
    pub const Left: Self = Self(1 << 3);
    #[doc(alias = "NSCollectionViewScrollPositionCenteredHorizontally")]
    pub const CenteredHorizontally: Self = Self(1 << 4);
    #[doc(alias = "NSCollectionViewScrollPositionRight")]
    pub const Right: Self = Self(1 << 5);
    #[doc(alias = "NSCollectionViewScrollPositionLeadingEdge")]
    pub const LeadingEdge: Self = Self(1 << 6);
    #[doc(alias = "NSCollectionViewScrollPositionTrailingEdge")]
    pub const TrailingEdge: Self = Self(1 << 7);
    #[doc(alias = "NSCollectionViewScrollPositionNearestVerticalEdge")]
    pub const NearestVerticalEdge: Self = Self(1 << 8);
}

unsafe impl Encode for NSCollectionViewScrollPosition {
    const ENCODING: Encoding = NSUInteger::ENCODING;
}

unsafe impl RefEncode for NSCollectionViewScrollPosition {
    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}

pub type NSCollectionViewSupplementaryElementKind = NSString;

extern_protocol!(
    #[cfg(feature = "NSUserInterfaceItemIdentification")]
    pub unsafe trait NSCollectionViewElement:
        NSObjectProtocol + NSUserInterfaceItemIdentification + IsMainThreadOnly
    {
        #[optional]
        #[method(prepareForReuse)]
        unsafe fn prepareForReuse(&self);

        #[cfg(feature = "NSCollectionViewLayout")]
        #[optional]
        #[method(applyLayoutAttributes:)]
        unsafe fn applyLayoutAttributes(
            &self,
            layout_attributes: &NSCollectionViewLayoutAttributes,
        );

        #[cfg(feature = "NSCollectionViewLayout")]
        #[optional]
        #[method(willTransitionFromLayout:toLayout:)]
        unsafe fn willTransitionFromLayout_toLayout(
            &self,
            old_layout: &NSCollectionViewLayout,
            new_layout: &NSCollectionViewLayout,
        );

        #[cfg(feature = "NSCollectionViewLayout")]
        #[optional]
        #[method(didTransitionFromLayout:toLayout:)]
        unsafe fn didTransitionFromLayout_toLayout(
            &self,
            old_layout: &NSCollectionViewLayout,
            new_layout: &NSCollectionViewLayout,
        );

        #[cfg(feature = "NSCollectionViewLayout")]
        #[optional]
        #[method_id(@__retain_semantics Other preferredLayoutAttributesFittingAttributes:)]
        unsafe fn preferredLayoutAttributesFittingAttributes(
            &self,
            layout_attributes: &NSCollectionViewLayoutAttributes,
        ) -> Id<NSCollectionViewLayoutAttributes>;
    }

    #[cfg(feature = "NSUserInterfaceItemIdentification")]
    unsafe impl ProtocolType for dyn NSCollectionViewElement {}
);

extern_protocol!(
    #[cfg(feature = "NSUserInterfaceItemIdentification")]
    pub unsafe trait NSCollectionViewSectionHeaderView:
        NSCollectionViewElement + IsMainThreadOnly
    {
        #[cfg(all(
            feature = "NSButton",
            feature = "NSControl",
            feature = "NSResponder",
            feature = "NSView"
        ))]
        #[optional]
        #[method_id(@__retain_semantics Other sectionCollapseButton)]
        unsafe fn sectionCollapseButton(&self) -> Option<Id<NSButton>>;

        #[cfg(all(
            feature = "NSButton",
            feature = "NSControl",
            feature = "NSResponder",
            feature = "NSView"
        ))]
        #[optional]
        #[method(setSectionCollapseButton:)]
        unsafe fn setSectionCollapseButton(&self, section_collapse_button: Option<&NSButton>);
    }

    #[cfg(feature = "NSUserInterfaceItemIdentification")]
    unsafe impl ProtocolType for dyn NSCollectionViewSectionHeaderView {}
);

extern_class!(
    #[derive(Debug, PartialEq, Eq, Hash)]
    #[cfg(all(feature = "NSResponder", feature = "NSViewController"))]
    pub struct NSCollectionViewItem;

    #[cfg(all(feature = "NSResponder", feature = "NSViewController"))]
    unsafe impl ClassType for NSCollectionViewItem {
        #[inherits(NSResponder, NSObject)]
        type Super = NSViewController;
        type Mutability = MainThreadOnly;
    }
);

#[cfg(all(feature = "NSResponder", feature = "NSViewController"))]
unsafe impl NSCoding for NSCollectionViewItem {}

#[cfg(all(
    feature = "NSResponder",
    feature = "NSUserInterfaceItemIdentification",
    feature = "NSViewController"
))]
unsafe impl NSCollectionViewElement for NSCollectionViewItem {}

#[cfg(all(feature = "NSResponder", feature = "NSViewController"))]
unsafe impl NSCopying for NSCollectionViewItem {}

#[cfg(all(
    feature = "NSKeyValueBinding",
    feature = "NSResponder",
    feature = "NSViewController"
))]
unsafe impl NSEditor for NSCollectionViewItem {}

#[cfg(all(feature = "NSResponder", feature = "NSViewController"))]
unsafe impl NSObjectProtocol for NSCollectionViewItem {}

#[cfg(all(
    feature = "NSResponder",
    feature = "NSStoryboardSegue",
    feature = "NSViewController"
))]
unsafe impl NSSeguePerforming for NSCollectionViewItem {}

#[cfg(all(
    feature = "NSResponder",
    feature = "NSUserInterfaceItemIdentification",
    feature = "NSViewController"
))]
unsafe impl NSUserInterfaceItemIdentification for NSCollectionViewItem {}

extern_methods!(
    #[cfg(all(feature = "NSResponder", feature = "NSViewController"))]
    unsafe impl NSCollectionViewItem {
        #[cfg(feature = "NSView")]
        #[method_id(@__retain_semantics Other collectionView)]
        pub unsafe fn collectionView(&self) -> Option<Id<NSCollectionView>>;

        #[method(isSelected)]
        pub unsafe fn isSelected(&self) -> bool;

        #[method(setSelected:)]
        pub unsafe fn setSelected(&self, selected: bool);

        #[method(highlightState)]
        pub unsafe fn highlightState(&self) -> NSCollectionViewItemHighlightState;

        #[method(setHighlightState:)]
        pub unsafe fn setHighlightState(&self, highlight_state: NSCollectionViewItemHighlightState);

        #[cfg(all(feature = "NSControl", feature = "NSImageView", feature = "NSView"))]
        #[method_id(@__retain_semantics Other imageView)]
        pub unsafe fn imageView(&self) -> Option<Id<NSImageView>>;

        #[cfg(all(feature = "NSControl", feature = "NSImageView", feature = "NSView"))]
        #[method(setImageView:)]
        pub unsafe fn setImageView(&self, image_view: Option<&NSImageView>);

        #[cfg(all(feature = "NSControl", feature = "NSTextField", feature = "NSView"))]
        #[method_id(@__retain_semantics Other textField)]
        pub unsafe fn textField(&self) -> Option<Id<NSTextField>>;

        #[cfg(all(feature = "NSControl", feature = "NSTextField", feature = "NSView"))]
        #[method(setTextField:)]
        pub unsafe fn setTextField(&self, text_field: Option<&NSTextField>);

        #[cfg(feature = "NSDraggingItem")]
        #[method_id(@__retain_semantics Other draggingImageComponents)]
        pub unsafe fn draggingImageComponents(&self) -> Id<NSArray<NSDraggingImageComponent>>;
    }
);

extern_methods!(
    /// Methods declared on superclass `NSViewController`
    #[cfg(all(feature = "NSResponder", feature = "NSViewController"))]
    unsafe impl NSCollectionViewItem {
        #[cfg(feature = "NSNib")]
        #[method_id(@__retain_semantics Init initWithNibName:bundle:)]
        pub unsafe fn initWithNibName_bundle(
            this: Allocated<Self>,
            nib_name_or_nil: Option<&NSNibName>,
            nib_bundle_or_nil: Option<&NSBundle>,
        ) -> Id<Self>;

        #[method_id(@__retain_semantics Init initWithCoder:)]
        pub unsafe fn initWithCoder(this: Allocated<Self>, coder: &NSCoder) -> Option<Id<Self>>;
    }
);

extern_methods!(
    /// Methods declared on superclass `NSResponder`
    #[cfg(all(feature = "NSResponder", feature = "NSViewController"))]
    unsafe impl NSCollectionViewItem {
        #[method_id(@__retain_semantics Init init)]
        pub unsafe fn init(this: Allocated<Self>) -> Id<Self>;
    }
);

extern_methods!(
    /// Methods declared on superclass `NSObject`
    #[cfg(all(feature = "NSResponder", feature = "NSViewController"))]
    unsafe impl NSCollectionViewItem {
        #[method_id(@__retain_semantics New new)]
        pub unsafe fn new(mtm: MainThreadMarker) -> Id<Self>;
    }
);

extern_class!(
    #[derive(Debug, PartialEq, Eq, Hash)]
    #[cfg(all(feature = "NSResponder", feature = "NSView"))]
    pub struct NSCollectionView;

    #[cfg(all(feature = "NSResponder", feature = "NSView"))]
    unsafe impl ClassType for NSCollectionView {
        #[inherits(NSResponder, NSObject)]
        type Super = NSView;
        type Mutability = MainThreadOnly;
    }
);

#[cfg(all(
    feature = "NSAccessibilityProtocols",
    feature = "NSResponder",
    feature = "NSView"
))]
unsafe impl NSAccessibility for NSCollectionView {}

#[cfg(all(
    feature = "NSAccessibilityProtocols",
    feature = "NSResponder",
    feature = "NSView"
))]
unsafe impl NSAccessibilityElementProtocol for NSCollectionView {}

#[cfg(all(feature = "NSAnimation", feature = "NSResponder", feature = "NSView"))]
unsafe impl NSAnimatablePropertyContainer for NSCollectionView {}

#[cfg(all(feature = "NSAppearance", feature = "NSResponder", feature = "NSView"))]
unsafe impl NSAppearanceCustomization for NSCollectionView {}

#[cfg(all(feature = "NSResponder", feature = "NSView"))]
unsafe impl NSCoding for NSCollectionView {}

#[cfg(all(feature = "NSDragging", feature = "NSResponder", feature = "NSView"))]
unsafe impl NSDraggingDestination for NSCollectionView {}

#[cfg(all(feature = "NSDragging", feature = "NSResponder", feature = "NSView"))]
unsafe impl NSDraggingSource for NSCollectionView {}

#[cfg(all(feature = "NSResponder", feature = "NSView"))]
unsafe impl NSObjectProtocol for NSCollectionView {}

#[cfg(all(
    feature = "NSResponder",
    feature = "NSUserInterfaceItemIdentification",
    feature = "NSView"
))]
unsafe impl NSUserInterfaceItemIdentification for NSCollectionView {}

extern_methods!(
    #[cfg(all(feature = "NSResponder", feature = "NSView"))]
    unsafe impl NSCollectionView {
        #[method_id(@__retain_semantics Other dataSource)]
        pub unsafe fn dataSource(
            &self,
        ) -> Option<Id<ProtocolObject<dyn NSCollectionViewDataSource>>>;

        #[method(setDataSource:)]
        pub unsafe fn setDataSource(
            &self,
            data_source: Option<&ProtocolObject<dyn NSCollectionViewDataSource>>,
        );

        #[method_id(@__retain_semantics Other prefetchDataSource)]
        pub unsafe fn prefetchDataSource(
            &self,
        ) -> Option<Id<ProtocolObject<dyn NSCollectionViewPrefetching>>>;

        #[method(setPrefetchDataSource:)]
        pub unsafe fn setPrefetchDataSource(
            &self,
            prefetch_data_source: Option<&ProtocolObject<dyn NSCollectionViewPrefetching>>,
        );

        #[method_id(@__retain_semantics Other content)]
        pub unsafe fn content(&self) -> Id<NSArray<AnyObject>>;

        #[method(setContent:)]
        pub unsafe fn setContent(&self, content: &NSArray<AnyObject>);

        #[method(reloadData)]
        pub unsafe fn reloadData(&self);

        #[method_id(@__retain_semantics Other delegate)]
        pub unsafe fn delegate(&self) -> Option<Id<ProtocolObject<dyn NSCollectionViewDelegate>>>;

        #[method(setDelegate:)]
        pub unsafe fn setDelegate(
            &self,
            delegate: Option<&ProtocolObject<dyn NSCollectionViewDelegate>>,
        );

        #[method_id(@__retain_semantics Other backgroundView)]
        pub unsafe fn backgroundView(&self) -> Option<Id<NSView>>;

        #[method(setBackgroundView:)]
        pub unsafe fn setBackgroundView(&self, background_view: Option<&NSView>);

        #[method(backgroundViewScrollsWithContent)]
        pub unsafe fn backgroundViewScrollsWithContent(&self) -> bool;

        #[method(setBackgroundViewScrollsWithContent:)]
        pub unsafe fn setBackgroundViewScrollsWithContent(
            &self,
            background_view_scrolls_with_content: bool,
        );

        #[cfg(feature = "NSCollectionViewLayout")]
        #[method_id(@__retain_semantics Other collectionViewLayout)]
        pub unsafe fn collectionViewLayout(&self) -> Option<Id<NSCollectionViewLayout>>;

        #[cfg(feature = "NSCollectionViewLayout")]
        #[method(setCollectionViewLayout:)]
        pub unsafe fn setCollectionViewLayout(
            &self,
            collection_view_layout: Option<&NSCollectionViewLayout>,
        );

        #[cfg(feature = "NSCollectionViewLayout")]
        #[method_id(@__retain_semantics Other layoutAttributesForItemAtIndexPath:)]
        pub unsafe fn layoutAttributesForItemAtIndexPath(
            &self,
            index_path: &NSIndexPath,
        ) -> Option<Id<NSCollectionViewLayoutAttributes>>;

        #[cfg(feature = "NSCollectionViewLayout")]
        #[method_id(@__retain_semantics Other layoutAttributesForSupplementaryElementOfKind:atIndexPath:)]
        pub unsafe fn layoutAttributesForSupplementaryElementOfKind_atIndexPath(
            &self,
            kind: &NSCollectionViewSupplementaryElementKind,
            index_path: &NSIndexPath,
        ) -> Option<Id<NSCollectionViewLayoutAttributes>>;

        #[method(frameForItemAtIndex:)]
        pub unsafe fn frameForItemAtIndex(&self, index: NSUInteger) -> NSRect;

        #[method(frameForItemAtIndex:withNumberOfItems:)]
        pub unsafe fn frameForItemAtIndex_withNumberOfItems(
            &self,
            index: NSUInteger,
            number_of_items: NSUInteger,
        ) -> NSRect;

        #[cfg(feature = "NSColor")]
        #[method_id(@__retain_semantics Other backgroundColors)]
        pub unsafe fn backgroundColors(&self) -> Id<NSArray<NSColor>>;

        #[cfg(feature = "NSColor")]
        #[method(setBackgroundColors:)]
        pub unsafe fn setBackgroundColors(&self, background_colors: Option<&NSArray<NSColor>>);

        #[method(numberOfSections)]
        pub unsafe fn numberOfSections(&self) -> NSInteger;

        #[method(numberOfItemsInSection:)]
        pub unsafe fn numberOfItemsInSection(&self, section: NSInteger) -> NSInteger;

        #[method(isFirstResponder)]
        pub unsafe fn isFirstResponder(&self) -> bool;

        #[method(isSelectable)]
        pub unsafe fn isSelectable(&self) -> bool;

        #[method(setSelectable:)]
        pub unsafe fn setSelectable(&self, selectable: bool);

        #[method(allowsEmptySelection)]
        pub unsafe fn allowsEmptySelection(&self) -> bool;

        #[method(setAllowsEmptySelection:)]
        pub unsafe fn setAllowsEmptySelection(&self, allows_empty_selection: bool);

        #[method(allowsMultipleSelection)]
        pub unsafe fn allowsMultipleSelection(&self) -> bool;

        #[method(setAllowsMultipleSelection:)]
        pub unsafe fn setAllowsMultipleSelection(&self, allows_multiple_selection: bool);

        #[method_id(@__retain_semantics Other selectionIndexes)]
        pub unsafe fn selectionIndexes(&self) -> Id<NSIndexSet>;

        #[method(setSelectionIndexes:)]
        pub unsafe fn setSelectionIndexes(&self, selection_indexes: &NSIndexSet);

        #[method_id(@__retain_semantics Other selectionIndexPaths)]
        pub unsafe fn selectionIndexPaths(&self) -> Id<NSSet<NSIndexPath>>;

        #[method(setSelectionIndexPaths:)]
        pub unsafe fn setSelectionIndexPaths(&self, selection_index_paths: &NSSet<NSIndexPath>);

        #[method(selectItemsAtIndexPaths:scrollPosition:)]
        pub unsafe fn selectItemsAtIndexPaths_scrollPosition(
            &self,
            index_paths: &NSSet<NSIndexPath>,
            scroll_position: NSCollectionViewScrollPosition,
        );

        #[method(deselectItemsAtIndexPaths:)]
        pub unsafe fn deselectItemsAtIndexPaths(&self, index_paths: &NSSet<NSIndexPath>);

        #[method(selectAll:)]
        pub unsafe fn selectAll(&self, sender: Option<&AnyObject>);

        #[method(deselectAll:)]
        pub unsafe fn deselectAll(&self, sender: Option<&AnyObject>);

        #[cfg(feature = "NSUserInterfaceItemIdentification")]
        #[method(registerClass:forItemWithIdentifier:)]
        pub unsafe fn registerClass_forItemWithIdentifier(
            &self,
            item_class: Option<&AnyClass>,
            identifier: &NSUserInterfaceItemIdentifier,
        );

        #[cfg(all(feature = "NSNib", feature = "NSUserInterfaceItemIdentification"))]
        #[method(registerNib:forItemWithIdentifier:)]
        pub unsafe fn registerNib_forItemWithIdentifier(
            &self,
            nib: Option<&NSNib>,
            identifier: &NSUserInterfaceItemIdentifier,
        );

        #[cfg(feature = "NSUserInterfaceItemIdentification")]
        #[method(registerClass:forSupplementaryViewOfKind:withIdentifier:)]
        pub unsafe fn registerClass_forSupplementaryViewOfKind_withIdentifier(
            &self,
            view_class: Option<&AnyClass>,
            kind: &NSCollectionViewSupplementaryElementKind,
            identifier: &NSUserInterfaceItemIdentifier,
        );

        #[cfg(all(feature = "NSNib", feature = "NSUserInterfaceItemIdentification"))]
        #[method(registerNib:forSupplementaryViewOfKind:withIdentifier:)]
        pub unsafe fn registerNib_forSupplementaryViewOfKind_withIdentifier(
            &self,
            nib: Option<&NSNib>,
            kind: &NSCollectionViewSupplementaryElementKind,
            identifier: &NSUserInterfaceItemIdentifier,
        );

        #[cfg(all(
            feature = "NSUserInterfaceItemIdentification",
            feature = "NSViewController"
        ))]
        #[method_id(@__retain_semantics Other makeItemWithIdentifier:forIndexPath:)]
        pub unsafe fn makeItemWithIdentifier_forIndexPath(
            &self,
            identifier: &NSUserInterfaceItemIdentifier,
            index_path: &NSIndexPath,
        ) -> Id<NSCollectionViewItem>;

        #[cfg(feature = "NSUserInterfaceItemIdentification")]
        #[method_id(@__retain_semantics Other makeSupplementaryViewOfKind:withIdentifier:forIndexPath:)]
        pub unsafe fn makeSupplementaryViewOfKind_withIdentifier_forIndexPath(
            &self,
            element_kind: &NSCollectionViewSupplementaryElementKind,
            identifier: &NSUserInterfaceItemIdentifier,
            index_path: &NSIndexPath,
        ) -> Id<NSView>;

        #[cfg(feature = "NSViewController")]
        #[method_id(@__retain_semantics Other itemAtIndex:)]
        pub unsafe fn itemAtIndex(&self, index: NSUInteger) -> Option<Id<NSCollectionViewItem>>;

        #[cfg(feature = "NSViewController")]
        #[method_id(@__retain_semantics Other itemAtIndexPath:)]
        pub unsafe fn itemAtIndexPath(
            &self,
            index_path: &NSIndexPath,
        ) -> Option<Id<NSCollectionViewItem>>;

        #[cfg(feature = "NSViewController")]
        #[method_id(@__retain_semantics Other visibleItems)]
        pub unsafe fn visibleItems(&self) -> Id<NSArray<NSCollectionViewItem>>;

        #[method_id(@__retain_semantics Other indexPathsForVisibleItems)]
        pub unsafe fn indexPathsForVisibleItems(&self) -> Id<NSSet<NSIndexPath>>;

        #[cfg(feature = "NSViewController")]
        #[method_id(@__retain_semantics Other indexPathForItem:)]
        pub unsafe fn indexPathForItem(
            &self,
            item: &NSCollectionViewItem,
        ) -> Option<Id<NSIndexPath>>;

        #[method_id(@__retain_semantics Other indexPathForItemAtPoint:)]
        pub unsafe fn indexPathForItemAtPoint(&self, point: NSPoint) -> Option<Id<NSIndexPath>>;

        #[cfg(feature = "NSUserInterfaceItemIdentification")]
        #[method_id(@__retain_semantics Other supplementaryViewForElementKind:atIndexPath:)]
        pub unsafe fn supplementaryViewForElementKind_atIndexPath(
            &self,
            element_kind: &NSCollectionViewSupplementaryElementKind,
            index_path: &NSIndexPath,
        ) -> Option<Id<NSView>>;

        #[cfg(feature = "NSUserInterfaceItemIdentification")]
        #[method_id(@__retain_semantics Other visibleSupplementaryViewsOfKind:)]
        pub unsafe fn visibleSupplementaryViewsOfKind(
            &self,
            element_kind: &NSCollectionViewSupplementaryElementKind,
        ) -> Id<NSArray<NSView>>;

        #[method_id(@__retain_semantics Other indexPathsForVisibleSupplementaryElementsOfKind:)]
        pub unsafe fn indexPathsForVisibleSupplementaryElementsOfKind(
            &self,
            element_kind: &NSCollectionViewSupplementaryElementKind,
        ) -> Id<NSSet<NSIndexPath>>;

        #[method(insertSections:)]
        pub unsafe fn insertSections(&self, sections: &NSIndexSet);

        #[method(deleteSections:)]
        pub unsafe fn deleteSections(&self, sections: &NSIndexSet);

        #[method(reloadSections:)]
        pub unsafe fn reloadSections(&self, sections: &NSIndexSet);

        #[method(moveSection:toSection:)]
        pub unsafe fn moveSection_toSection(&self, section: NSInteger, new_section: NSInteger);

        #[method(insertItemsAtIndexPaths:)]
        pub unsafe fn insertItemsAtIndexPaths(&self, index_paths: &NSSet<NSIndexPath>);

        #[method(deleteItemsAtIndexPaths:)]
        pub unsafe fn deleteItemsAtIndexPaths(&self, index_paths: &NSSet<NSIndexPath>);

        #[method(reloadItemsAtIndexPaths:)]
        pub unsafe fn reloadItemsAtIndexPaths(&self, index_paths: &NSSet<NSIndexPath>);

        #[method(moveItemAtIndexPath:toIndexPath:)]
        pub unsafe fn moveItemAtIndexPath_toIndexPath(
            &self,
            index_path: &NSIndexPath,
            new_index_path: &NSIndexPath,
        );

        #[cfg(feature = "block2")]
        #[method(performBatchUpdates:completionHandler:)]
        pub unsafe fn performBatchUpdates_completionHandler(
            &self,
            updates: Option<&Block<dyn Fn() + '_>>,
            completion_handler: Option<&Block<dyn Fn(Bool)>>,
        );

        #[method(toggleSectionCollapse:)]
        pub unsafe fn toggleSectionCollapse(&self, sender: &AnyObject);

        #[method(scrollToItemsAtIndexPaths:scrollPosition:)]
        pub unsafe fn scrollToItemsAtIndexPaths_scrollPosition(
            &self,
            index_paths: &NSSet<NSIndexPath>,
            scroll_position: NSCollectionViewScrollPosition,
        );

        #[cfg(feature = "NSDragging")]
        #[method(setDraggingSourceOperationMask:forLocal:)]
        pub unsafe fn setDraggingSourceOperationMask_forLocal(
            &self,
            drag_operation_mask: NSDragOperation,
            local_destination: bool,
        );

        #[cfg(all(feature = "NSEvent", feature = "NSImage"))]
        #[method_id(@__retain_semantics Other draggingImageForItemsAtIndexPaths:withEvent:offset:)]
        pub unsafe fn draggingImageForItemsAtIndexPaths_withEvent_offset(
            &self,
            index_paths: &NSSet<NSIndexPath>,
            event: &NSEvent,
            drag_image_offset: NSPointPointer,
        ) -> Id<NSImage>;

        #[cfg(all(feature = "NSEvent", feature = "NSImage"))]
        #[method_id(@__retain_semantics Other draggingImageForItemsAtIndexes:withEvent:offset:)]
        pub unsafe fn draggingImageForItemsAtIndexes_withEvent_offset(
            &self,
            indexes: &NSIndexSet,
            event: &NSEvent,
            drag_image_offset: NSPointPointer,
        ) -> Id<NSImage>;
    }
);

extern_methods!(
    /// Methods declared on superclass `NSView`
    #[cfg(all(feature = "NSResponder", feature = "NSView"))]
    unsafe impl NSCollectionView {
        #[method_id(@__retain_semantics Init initWithFrame:)]
        pub unsafe fn initWithFrame(this: Allocated<Self>, frame_rect: NSRect) -> Id<Self>;

        #[method_id(@__retain_semantics Init initWithCoder:)]
        pub unsafe fn initWithCoder(this: Allocated<Self>, coder: &NSCoder) -> Option<Id<Self>>;
    }
);

extern_methods!(
    /// Methods declared on superclass `NSResponder`
    #[cfg(all(feature = "NSResponder", feature = "NSView"))]
    unsafe impl NSCollectionView {
        #[method_id(@__retain_semantics Init init)]
        pub unsafe fn init(this: Allocated<Self>) -> Id<Self>;
    }
);

extern_methods!(
    /// Methods declared on superclass `NSObject`
    #[cfg(all(feature = "NSResponder", feature = "NSView"))]
    unsafe impl NSCollectionView {
        #[method_id(@__retain_semantics New new)]
        pub unsafe fn new(mtm: MainThreadMarker) -> Id<Self>;
    }
);

extern_protocol!(
    pub unsafe trait NSCollectionViewDataSource:
        NSObjectProtocol + IsMainThreadOnly
    {
        #[cfg(all(feature = "NSResponder", feature = "NSView"))]
        #[method(collectionView:numberOfItemsInSection:)]
        unsafe fn collectionView_numberOfItemsInSection(
            &self,
            collection_view: &NSCollectionView,
            section: NSInteger,
        ) -> NSInteger;

        #[cfg(all(
            feature = "NSResponder",
            feature = "NSView",
            feature = "NSViewController"
        ))]
        #[method_id(@__retain_semantics Other collectionView:itemForRepresentedObjectAtIndexPath:)]
        unsafe fn collectionView_itemForRepresentedObjectAtIndexPath(
            &self,
            collection_view: &NSCollectionView,
            index_path: &NSIndexPath,
        ) -> Id<NSCollectionViewItem>;

        #[cfg(all(feature = "NSResponder", feature = "NSView"))]
        #[optional]
        #[method(numberOfSectionsInCollectionView:)]
        unsafe fn numberOfSectionsInCollectionView(
            &self,
            collection_view: &NSCollectionView,
        ) -> NSInteger;

        #[cfg(all(feature = "NSResponder", feature = "NSView"))]
        #[optional]
        #[method_id(@__retain_semantics Other collectionView:viewForSupplementaryElementOfKind:atIndexPath:)]
        unsafe fn collectionView_viewForSupplementaryElementOfKind_atIndexPath(
            &self,
            collection_view: &NSCollectionView,
            kind: &NSCollectionViewSupplementaryElementKind,
            index_path: &NSIndexPath,
        ) -> Id<NSView>;
    }

    unsafe impl ProtocolType for dyn NSCollectionViewDataSource {}
);

extern_protocol!(
    pub unsafe trait NSCollectionViewPrefetching:
        NSObjectProtocol + IsMainThreadOnly
    {
        #[cfg(all(feature = "NSResponder", feature = "NSView"))]
        #[method(collectionView:prefetchItemsAtIndexPaths:)]
        unsafe fn collectionView_prefetchItemsAtIndexPaths(
            &self,
            collection_view: &NSCollectionView,
            index_paths: &NSArray<NSIndexPath>,
        );

        #[cfg(all(feature = "NSResponder", feature = "NSView"))]
        #[optional]
        #[method(collectionView:cancelPrefetchingForItemsAtIndexPaths:)]
        unsafe fn collectionView_cancelPrefetchingForItemsAtIndexPaths(
            &self,
            collection_view: &NSCollectionView,
            index_paths: &NSArray<NSIndexPath>,
        );
    }

    unsafe impl ProtocolType for dyn NSCollectionViewPrefetching {}
);

extern_protocol!(
    pub unsafe trait NSCollectionViewDelegate: NSObjectProtocol {
        #[cfg(all(feature = "NSEvent", feature = "NSResponder", feature = "NSView"))]
        #[optional]
        #[method(collectionView:canDragItemsAtIndexPaths:withEvent:)]
        unsafe fn collectionView_canDragItemsAtIndexPaths_withEvent(
            &self,
            collection_view: &NSCollectionView,
            index_paths: &NSSet<NSIndexPath>,
            event: &NSEvent,
        ) -> bool;

        #[cfg(all(feature = "NSEvent", feature = "NSResponder", feature = "NSView"))]
        #[optional]
        #[method(collectionView:canDragItemsAtIndexes:withEvent:)]
        unsafe fn collectionView_canDragItemsAtIndexes_withEvent(
            &self,
            collection_view: &NSCollectionView,
            indexes: &NSIndexSet,
            event: &NSEvent,
        ) -> bool;

        #[cfg(all(feature = "NSPasteboard", feature = "NSResponder", feature = "NSView"))]
        #[deprecated = "Use -collectionView:pasteboardWriterForItemAtIndexPath: instead"]
        #[optional]
        #[method(collectionView:writeItemsAtIndexPaths:toPasteboard:)]
        unsafe fn collectionView_writeItemsAtIndexPaths_toPasteboard(
            &self,
            collection_view: &NSCollectionView,
            index_paths: &NSSet<NSIndexPath>,
            pasteboard: &NSPasteboard,
        ) -> bool;

        #[cfg(all(feature = "NSPasteboard", feature = "NSResponder", feature = "NSView"))]
        #[deprecated = "Use -collectionView:pasteboardWriterForItemAtIndexPath: instead"]
        #[optional]
        #[method(collectionView:writeItemsAtIndexes:toPasteboard:)]
        unsafe fn collectionView_writeItemsAtIndexes_toPasteboard(
            &self,
            collection_view: &NSCollectionView,
            indexes: &NSIndexSet,
            pasteboard: &NSPasteboard,
        ) -> bool;

        #[cfg(all(feature = "NSResponder", feature = "NSView"))]
        #[deprecated = "Use NSFilePromiseReceiver objects instead"]
        #[optional]
        #[method_id(@__retain_semantics Other collectionView:namesOfPromisedFilesDroppedAtDestination:forDraggedItemsAtIndexPaths:)]
        unsafe fn collectionView_namesOfPromisedFilesDroppedAtDestination_forDraggedItemsAtIndexPaths(
            &self,
            collection_view: &NSCollectionView,
            drop_url: &NSURL,
            index_paths: &NSSet<NSIndexPath>,
        ) -> Id<NSArray<NSString>>;

        #[cfg(all(feature = "NSResponder", feature = "NSView"))]
        #[deprecated = "Use NSFilePromiseReceiver objects instead"]
        #[optional]
        #[method_id(@__retain_semantics Other collectionView:namesOfPromisedFilesDroppedAtDestination:forDraggedItemsAtIndexes:)]
        unsafe fn collectionView_namesOfPromisedFilesDroppedAtDestination_forDraggedItemsAtIndexes(
            &self,
            collection_view: &NSCollectionView,
            drop_url: &NSURL,
            indexes: &NSIndexSet,
        ) -> Id<NSArray<NSString>>;

        #[cfg(all(
            feature = "NSEvent",
            feature = "NSImage",
            feature = "NSResponder",
            feature = "NSView"
        ))]
        #[optional]
        #[method_id(@__retain_semantics Other collectionView:draggingImageForItemsAtIndexPaths:withEvent:offset:)]
        unsafe fn collectionView_draggingImageForItemsAtIndexPaths_withEvent_offset(
            &self,
            collection_view: &NSCollectionView,
            index_paths: &NSSet<NSIndexPath>,
            event: &NSEvent,
            drag_image_offset: NSPointPointer,
        ) -> Id<NSImage>;

        #[cfg(all(
            feature = "NSEvent",
            feature = "NSImage",
            feature = "NSResponder",
            feature = "NSView"
        ))]
        #[optional]
        #[method_id(@__retain_semantics Other collectionView:draggingImageForItemsAtIndexes:withEvent:offset:)]
        unsafe fn collectionView_draggingImageForItemsAtIndexes_withEvent_offset(
            &self,
            collection_view: &NSCollectionView,
            indexes: &NSIndexSet,
            event: &NSEvent,
            drag_image_offset: NSPointPointer,
        ) -> Id<NSImage>;

        #[cfg(all(feature = "NSDragging", feature = "NSResponder", feature = "NSView"))]
        #[optional]
        #[method(collectionView:validateDrop:proposedIndexPath:dropOperation:)]
        unsafe fn collectionView_validateDrop_proposedIndexPath_dropOperation(
            &self,
            collection_view: &NSCollectionView,
            dragging_info: &ProtocolObject<dyn NSDraggingInfo>,
            proposed_drop_index_path: &mut Id<NSIndexPath>,
            proposed_drop_operation: NonNull<NSCollectionViewDropOperation>,
        ) -> NSDragOperation;

        #[cfg(all(feature = "NSDragging", feature = "NSResponder", feature = "NSView"))]
        #[optional]
        #[method(collectionView:validateDrop:proposedIndex:dropOperation:)]
        unsafe fn collectionView_validateDrop_proposedIndex_dropOperation(
            &self,
            collection_view: &NSCollectionView,
            dragging_info: &ProtocolObject<dyn NSDraggingInfo>,
            proposed_drop_index: NonNull<NSInteger>,
            proposed_drop_operation: NonNull<NSCollectionViewDropOperation>,
        ) -> NSDragOperation;

        #[cfg(all(feature = "NSDragging", feature = "NSResponder", feature = "NSView"))]
        #[optional]
        #[method(collectionView:acceptDrop:indexPath:dropOperation:)]
        unsafe fn collectionView_acceptDrop_indexPath_dropOperation(
            &self,
            collection_view: &NSCollectionView,
            dragging_info: &ProtocolObject<dyn NSDraggingInfo>,
            index_path: &NSIndexPath,
            drop_operation: NSCollectionViewDropOperation,
        ) -> bool;

        #[cfg(all(feature = "NSDragging", feature = "NSResponder", feature = "NSView"))]
        #[optional]
        #[method(collectionView:acceptDrop:index:dropOperation:)]
        unsafe fn collectionView_acceptDrop_index_dropOperation(
            &self,
            collection_view: &NSCollectionView,
            dragging_info: &ProtocolObject<dyn NSDraggingInfo>,
            index: NSInteger,
            drop_operation: NSCollectionViewDropOperation,
        ) -> bool;

        #[cfg(all(feature = "NSPasteboard", feature = "NSResponder", feature = "NSView"))]
        #[optional]
        #[method_id(@__retain_semantics Other collectionView:pasteboardWriterForItemAtIndexPath:)]
        unsafe fn collectionView_pasteboardWriterForItemAtIndexPath(
            &self,
            collection_view: &NSCollectionView,
            index_path: &NSIndexPath,
        ) -> Option<Id<ProtocolObject<dyn NSPasteboardWriting>>>;

        #[cfg(all(feature = "NSPasteboard", feature = "NSResponder", feature = "NSView"))]
        #[optional]
        #[method_id(@__retain_semantics Other collectionView:pasteboardWriterForItemAtIndex:)]
        unsafe fn collectionView_pasteboardWriterForItemAtIndex(
            &self,
            collection_view: &NSCollectionView,
            index: NSUInteger,
        ) -> Option<Id<ProtocolObject<dyn NSPasteboardWriting>>>;

        #[cfg(all(
            feature = "NSDraggingSession",
            feature = "NSResponder",
            feature = "NSView"
        ))]
        #[optional]
        #[method(collectionView:draggingSession:willBeginAtPoint:forItemsAtIndexPaths:)]
        unsafe fn collectionView_draggingSession_willBeginAtPoint_forItemsAtIndexPaths(
            &self,
            collection_view: &NSCollectionView,
            session: &NSDraggingSession,
            screen_point: NSPoint,
            index_paths: &NSSet<NSIndexPath>,
        );

        #[cfg(all(
            feature = "NSDraggingSession",
            feature = "NSResponder",
            feature = "NSView"
        ))]
        #[optional]
        #[method(collectionView:draggingSession:willBeginAtPoint:forItemsAtIndexes:)]
        unsafe fn collectionView_draggingSession_willBeginAtPoint_forItemsAtIndexes(
            &self,
            collection_view: &NSCollectionView,
            session: &NSDraggingSession,
            screen_point: NSPoint,
            indexes: &NSIndexSet,
        );

        #[cfg(all(
            feature = "NSDragging",
            feature = "NSDraggingSession",
            feature = "NSResponder",
            feature = "NSView"
        ))]
        #[optional]
        #[method(collectionView:draggingSession:endedAtPoint:dragOperation:)]
        unsafe fn collectionView_draggingSession_endedAtPoint_dragOperation(
            &self,
            collection_view: &NSCollectionView,
            session: &NSDraggingSession,
            screen_point: NSPoint,
            operation: NSDragOperation,
        );

        #[cfg(all(feature = "NSDragging", feature = "NSResponder", feature = "NSView"))]
        #[optional]
        #[method(collectionView:updateDraggingItemsForDrag:)]
        unsafe fn collectionView_updateDraggingItemsForDrag(
            &self,
            collection_view: &NSCollectionView,
            dragging_info: &ProtocolObject<dyn NSDraggingInfo>,
        );

        #[cfg(all(feature = "NSResponder", feature = "NSView"))]
        #[optional]
        #[method_id(@__retain_semantics Other collectionView:shouldChangeItemsAtIndexPaths:toHighlightState:)]
        unsafe fn collectionView_shouldChangeItemsAtIndexPaths_toHighlightState(
            &self,
            collection_view: &NSCollectionView,
            index_paths: &NSSet<NSIndexPath>,
            highlight_state: NSCollectionViewItemHighlightState,
        ) -> Id<NSSet<NSIndexPath>>;

        #[cfg(all(feature = "NSResponder", feature = "NSView"))]
        #[optional]
        #[method(collectionView:didChangeItemsAtIndexPaths:toHighlightState:)]
        unsafe fn collectionView_didChangeItemsAtIndexPaths_toHighlightState(
            &self,
            collection_view: &NSCollectionView,
            index_paths: &NSSet<NSIndexPath>,
            highlight_state: NSCollectionViewItemHighlightState,
        );

        #[cfg(all(feature = "NSResponder", feature = "NSView"))]
        #[optional]
        #[method_id(@__retain_semantics Other collectionView:shouldSelectItemsAtIndexPaths:)]
        unsafe fn collectionView_shouldSelectItemsAtIndexPaths(
            &self,
            collection_view: &NSCollectionView,
            index_paths: &NSSet<NSIndexPath>,
        ) -> Id<NSSet<NSIndexPath>>;

        #[cfg(all(feature = "NSResponder", feature = "NSView"))]
        #[optional]
        #[method_id(@__retain_semantics Other collectionView:shouldDeselectItemsAtIndexPaths:)]
        unsafe fn collectionView_shouldDeselectItemsAtIndexPaths(
            &self,
            collection_view: &NSCollectionView,
            index_paths: &NSSet<NSIndexPath>,
        ) -> Id<NSSet<NSIndexPath>>;

        #[cfg(all(feature = "NSResponder", feature = "NSView"))]
        #[optional]
        #[method(collectionView:didSelectItemsAtIndexPaths:)]
        unsafe fn collectionView_didSelectItemsAtIndexPaths(
            &self,
            collection_view: &NSCollectionView,
            index_paths: &NSSet<NSIndexPath>,
        );

        #[cfg(all(feature = "NSResponder", feature = "NSView"))]
        #[optional]
        #[method(collectionView:didDeselectItemsAtIndexPaths:)]
        unsafe fn collectionView_didDeselectItemsAtIndexPaths(
            &self,
            collection_view: &NSCollectionView,
            index_paths: &NSSet<NSIndexPath>,
        );

        #[cfg(all(
            feature = "NSResponder",
            feature = "NSView",
            feature = "NSViewController"
        ))]
        #[optional]
        #[method(collectionView:willDisplayItem:forRepresentedObjectAtIndexPath:)]
        unsafe fn collectionView_willDisplayItem_forRepresentedObjectAtIndexPath(
            &self,
            collection_view: &NSCollectionView,
            item: &NSCollectionViewItem,
            index_path: &NSIndexPath,
        );

        #[cfg(all(feature = "NSResponder", feature = "NSView"))]
        #[optional]
        #[method(collectionView:willDisplaySupplementaryView:forElementKind:atIndexPath:)]
        unsafe fn collectionView_willDisplaySupplementaryView_forElementKind_atIndexPath(
            &self,
            collection_view: &NSCollectionView,
            view: &NSView,
            element_kind: &NSCollectionViewSupplementaryElementKind,
            index_path: &NSIndexPath,
        );

        #[cfg(all(
            feature = "NSResponder",
            feature = "NSView",
            feature = "NSViewController"
        ))]
        #[optional]
        #[method(collectionView:didEndDisplayingItem:forRepresentedObjectAtIndexPath:)]
        unsafe fn collectionView_didEndDisplayingItem_forRepresentedObjectAtIndexPath(
            &self,
            collection_view: &NSCollectionView,
            item: &NSCollectionViewItem,
            index_path: &NSIndexPath,
        );

        #[cfg(all(feature = "NSResponder", feature = "NSView"))]
        #[optional]
        #[method(collectionView:didEndDisplayingSupplementaryView:forElementOfKind:atIndexPath:)]
        unsafe fn collectionView_didEndDisplayingSupplementaryView_forElementOfKind_atIndexPath(
            &self,
            collection_view: &NSCollectionView,
            view: &NSView,
            element_kind: &NSCollectionViewSupplementaryElementKind,
            index_path: &NSIndexPath,
        );

        #[cfg(all(
            feature = "NSCollectionViewLayout",
            feature = "NSCollectionViewTransitionLayout",
            feature = "NSResponder",
            feature = "NSView"
        ))]
        #[optional]
        #[method_id(@__retain_semantics Other collectionView:transitionLayoutForOldLayout:newLayout:)]
        unsafe fn collectionView_transitionLayoutForOldLayout_newLayout(
            &self,
            collection_view: &NSCollectionView,
            from_layout: &NSCollectionViewLayout,
            to_layout: &NSCollectionViewLayout,
        ) -> Id<NSCollectionViewTransitionLayout>;
    }

    unsafe impl ProtocolType for dyn NSCollectionViewDelegate {}
);

extern_category!(
    /// Category "NSCollectionViewAdditions" on [`NSIndexPath`].
    #[doc(alias = "NSCollectionViewAdditions")]
    pub unsafe trait NSIndexPathNSCollectionViewAdditions {
        #[method_id(@__retain_semantics Other indexPathForItem:inSection:)]
        unsafe fn indexPathForItem_inSection(
            item: NSInteger,
            section: NSInteger,
        ) -> Id<NSIndexPath>;

        #[method(item)]
        unsafe fn item(&self) -> NSInteger;

        #[method(section)]
        unsafe fn section(&self) -> NSInteger;
    }

    unsafe impl NSIndexPathNSCollectionViewAdditions for NSIndexPath {}
);

extern_category!(
    /// Category "NSCollectionViewAdditions" on [`NSSet`].
    #[doc(alias = "NSCollectionViewAdditions")]
    pub unsafe trait NSSetNSCollectionViewAdditions {
        #[method_id(@__retain_semantics Other setWithCollectionViewIndexPath:)]
        unsafe fn setWithCollectionViewIndexPath(index_path: &NSIndexPath) -> Id<Self>;

        #[method_id(@__retain_semantics Other setWithCollectionViewIndexPaths:)]
        unsafe fn setWithCollectionViewIndexPaths(index_paths: &NSArray<NSIndexPath>) -> Id<Self>;

        #[cfg(feature = "block2")]
        #[method(enumerateIndexPathsWithOptions:usingBlock:)]
        unsafe fn enumerateIndexPathsWithOptions_usingBlock(
            &self,
            opts: NSEnumerationOptions,
            block: &Block<dyn Fn(NonNull<NSIndexPath>, NonNull<Bool>) + '_>,
        );
    }

    unsafe impl NSSetNSCollectionViewAdditions for NSSet {}
);

extern_methods!(
    /// NSDeprecated
    #[cfg(all(feature = "NSResponder", feature = "NSView"))]
    unsafe impl NSCollectionView {
        #[cfg(feature = "NSViewController")]
        #[deprecated = "Use -[NSCollectionViewDataSource collectionView:itemForRepresentedObjectAtIndexPath:] instead"]
        #[method_id(@__retain_semantics New newItemForRepresentedObject:)]
        pub unsafe fn newItemForRepresentedObject(
            &self,
            object: &AnyObject,
        ) -> Id<NSCollectionViewItem>;

        #[cfg(feature = "NSViewController")]
        #[deprecated = "Use -registerNib:forItemWithIdentifier: or -registerClass:forItemWithIdentifier: instead."]
        #[method_id(@__retain_semantics Other itemPrototype)]
        pub unsafe fn itemPrototype(&self) -> Option<Id<NSCollectionViewItem>>;

        #[cfg(feature = "NSViewController")]
        #[deprecated = "Use -registerNib:forItemWithIdentifier: or -registerClass:forItemWithIdentifier: instead."]
        #[method(setItemPrototype:)]
        pub unsafe fn setItemPrototype(&self, item_prototype: Option<&NSCollectionViewItem>);

        #[deprecated = "Use NSCollectionViewGridLayout as the receiver's collectionViewLayout, setting its maximumNumberOfRows instead"]
        #[method(maxNumberOfRows)]
        pub unsafe fn maxNumberOfRows(&self) -> NSUInteger;

        #[deprecated = "Use NSCollectionViewGridLayout as the receiver's collectionViewLayout, setting its maximumNumberOfRows instead"]
        #[method(setMaxNumberOfRows:)]
        pub unsafe fn setMaxNumberOfRows(&self, max_number_of_rows: NSUInteger);

        #[deprecated = "Use NSCollectionViewGridLayout as the receiver's collectionViewLayout, setting its maximumNumberOfColumns instead"]
        #[method(maxNumberOfColumns)]
        pub unsafe fn maxNumberOfColumns(&self) -> NSUInteger;

        #[deprecated = "Use NSCollectionViewGridLayout as the receiver's collectionViewLayout, setting its maximumNumberOfColumns instead"]
        #[method(setMaxNumberOfColumns:)]
        pub unsafe fn setMaxNumberOfColumns(&self, max_number_of_columns: NSUInteger);

        #[deprecated = "Use NSCollectionViewGridLayout as the receiver's collectionViewLayout, setting its minimumItemSize instead"]
        #[method(minItemSize)]
        pub unsafe fn minItemSize(&self) -> NSSize;

        #[deprecated = "Use NSCollectionViewGridLayout as the receiver's collectionViewLayout, setting its minimumItemSize instead"]
        #[method(setMinItemSize:)]
        pub unsafe fn setMinItemSize(&self, min_item_size: NSSize);

        #[deprecated = "Use NSCollectionViewGridLayout as the receiver's collectionViewLayout, setting its maximumItemSize instead"]
        #[method(maxItemSize)]
        pub unsafe fn maxItemSize(&self) -> NSSize;

        #[deprecated = "Use NSCollectionViewGridLayout as the receiver's collectionViewLayout, setting its maximumItemSize instead"]
        #[method(setMaxItemSize:)]
        pub unsafe fn setMaxItemSize(&self, max_item_size: NSSize);
    }
);