@@ -41,7 +41,7 @@ open class CollectionView : ScrollView, NSDraggingSource {
4141
4242
4343 /// The object that acts as the delegate to the collection view
44- public weak var delegate : CollectionViewDelegate ?
44+ @ objc public weak var delegate : CollectionViewDelegate ?
4545
4646 /// The object that provides data for the collection view
4747 public weak var dataSource : CollectionViewDataSource ?
@@ -84,9 +84,9 @@ open class CollectionView : ScrollView, NSDraggingSource {
8484 self . hasVerticalScroller = true
8585 self . scrollsDynamically = true
8686
87- NotificationCenter . default. addObserver ( self , selector: #selector( CollectionView . didScroll ( _: ) ) , name: NSNotification . Name . NSScrollViewDidLiveScroll , object: self )
88- NotificationCenter . default. addObserver ( self , selector: #selector( CollectionView . willBeginScroll ( _: ) ) , name: NSNotification . Name . NSScrollViewWillStartLiveScroll , object: self )
89- NotificationCenter . default. addObserver ( self , selector: #selector( CollectionView . didEndScroll ( _: ) ) , name: NSNotification . Name . NSScrollViewDidEndLiveScroll , object: self )
87+ NotificationCenter . default. addObserver ( self , selector: #selector( CollectionView . didScroll ( _: ) ) , name: NSScrollView . didLiveScrollNotification , object: self )
88+ NotificationCenter . default. addObserver ( self , selector: #selector( CollectionView . willBeginScroll ( _: ) ) , name: NSScrollView . willStartLiveScrollNotification , object: self )
89+ NotificationCenter . default. addObserver ( self , selector: #selector( CollectionView . didEndScroll ( _: ) ) , name: NSScrollView . didEndLiveScrollNotification , object: self )
9090
9191 self . addSubview ( _floatingSupplementaryView, positioned: . above, relativeTo: self . clipView!)
9292 self . _floatingSupplementaryView. wantsLayer = true
@@ -114,7 +114,7 @@ open class CollectionView : ScrollView, NSDraggingSource {
114114 }
115115 }
116116
117- open override var scrollerStyle : NSScrollerStyle {
117+ open override var scrollerStyle : NSScroller . Style {
118118 didSet {
119119// log.debug("Scroller Style changed")
120120 self . reloadLayout ( false )
@@ -211,9 +211,10 @@ open class CollectionView : ScrollView, NSDraggingSource {
211211 internal var _registeredSupplementaryViewKinds = Set < String > ( )
212212 private func _firstObjectOfClass( _ aClass: AnyClass , inNib: NSNib ) -> NSView ? {
213213 var foundObject : AnyObject ? = nil
214- var topLevelObjects = NSArray ( )
215- if inNib. instantiate ( withOwner: self , topLevelObjects: & topLevelObjects) {
216- for obj in topLevelObjects {
214+ var topLevelObjects : NSArray ?
215+
216+ if inNib. instantiate ( withOwner: self , topLevelObjects: & topLevelObjects) , let objects = topLevelObjects {
217+ for obj in objects {
217218 if let o = obj as? NSView , o. isKind ( of: aClass) {
218219 foundObject = o
219220 break
@@ -727,7 +728,7 @@ open class CollectionView : ScrollView, NSDraggingSource {
727728
728729 // MARK: - Scroll Handling
729730 /*-------------------------------------------------------------------------------*/
730- override open class func isCompatibleWithResponsiveScrolling( ) -> Bool { return true }
731+ override open class var isCompatibleWithResponsiveScrolling : Bool { return true }
731732
732733 public var isScrollEnabled : Bool {
733734 set { self . clipView? . scrollEnabled = newValue }
@@ -786,7 +787,7 @@ open class CollectionView : ScrollView, NSDraggingSource {
786787 public private( set) var peakScrollVelocity = CGPoint . zero
787788
788789
789- final func didScroll( _ notification: Notification ) {
790+ @ objc final func didScroll( _ notification: Notification ) {
790791 let rect = _preperationRect
791792 self . contentDocumentView. prepareRect ( rect)
792793
@@ -802,22 +803,22 @@ open class CollectionView : ScrollView, NSDraggingSource {
802803 self . delegate? . collectionViewDidScroll ? ( self )
803804 }
804805
805- final func willBeginScroll( _ notification: Notification ) {
806+ @ objc final func willBeginScroll( _ notification: Notification ) {
806807 self . isScrolling = true
807808 self . delegate? . collectionViewWillBeginScrolling ? ( self )
808809 self . _previousOffset = self . contentVisibleRect. origin
809810 self . peakScrollVelocity = CGPoint . zero
810811 self . scrollVelocity = CGPoint . zero
811812 }
812813
813- final func didEndScroll( _ notification: Notification ) {
814+ @ objc final func didEndScroll( _ notification: Notification ) {
814815 self . isScrolling = false
815816
816817 self . delegate? . collectionViewDidEndScrolling ? ( self , animated: true )
817818 self . scrollVelocity = CGPoint . zero
818819 self . peakScrollVelocity = CGPoint . zero
819820
820- if trackSectionHover && NSApp . isActive, let point = self . window? . convertFromScreen ( NSRect ( origin: NSEvent . mouseLocation ( ) , size: CGSize . zero) ) . origin {
821+ if trackSectionHover && NSApp . isActive, let point = self . window? . convertFromScreen ( NSRect ( origin: NSEvent . mouseLocation, size: CGSize . zero) ) . origin {
821822 let loc = self . contentDocumentView. convert ( point, from: nil )
822823 self . delegate? . collectionView ? ( self , mouseMovedToSection: indexPathForSection ( at: loc) )
823824 }
@@ -1530,7 +1531,7 @@ open class CollectionView : ScrollView, NSDraggingSource {
15301531 self . removeTrackingArea ( ta)
15311532 }
15321533 if trackSectionHover {
1533- _trackingArea = NSTrackingArea ( rect: self . bounds, options: [ NSTrackingAreaOptions . activeInActiveApp, NSTrackingAreaOptions . mouseEnteredAndExited, NSTrackingAreaOptions . mouseMoved] , owner: self , userInfo: nil )
1534+ _trackingArea = NSTrackingArea ( rect: self . bounds, options: [ NSTrackingArea . Options . activeInActiveApp, NSTrackingArea . Options . mouseEnteredAndExited, NSTrackingArea . Options . mouseMoved] , owner: self , userInfo: nil )
15341535 self . addTrackingArea ( _trackingArea!)
15351536 }
15361537 }
@@ -1621,7 +1622,7 @@ open class CollectionView : ScrollView, NSDraggingSource {
16211622 self . _deselectAllItems ( true , notify: true )
16221623 }
16231624
1624- if theEvent. modifierFlags. contains ( NSEventModifierFlags . control) {
1625+ if theEvent. modifierFlags. contains ( NSEvent . ModifierFlags . control) {
16251626 self . rightMouseDown ( with: theEvent)
16261627 return
16271628 }
@@ -1635,10 +1636,10 @@ open class CollectionView : ScrollView, NSDraggingSource {
16351636
16361637 guard ip == mouseDownIP else { return }
16371638
1638- if allowsMultipleSelection && theEvent. modifierFlags. contains ( NSEventModifierFlags . shift) {
1639+ if allowsMultipleSelection && theEvent. modifierFlags. contains ( NSEvent . ModifierFlags . shift) {
16391640 self . _selectItem ( at: ip, atScrollPosition: . nearest, animated: true , selectionType: . extending)
16401641 }
1641- else if allowsMultipleSelection && theEvent. modifierFlags. contains ( NSEventModifierFlags . command) {
1642+ else if allowsMultipleSelection && theEvent. modifierFlags. contains ( NSEvent . ModifierFlags . command) {
16421643 if self . _selectedIndexPaths. contains ( ip) {
16431644 if self . _selectedIndexPaths. count == 1 { return }
16441645 self . _deselectItem ( at: ip, animated: true , notifyDelegate: true )
@@ -1701,7 +1702,7 @@ open class CollectionView : ScrollView, NSDraggingSource {
17011702 else {
17021703 lastEventTime = nil
17031704 }
1704- let extend = selectionMode == . multi || theEvent. modifierFlags. contains ( NSEventModifierFlags . shift)
1705+ let extend = selectionMode == . multi || theEvent. modifierFlags. contains ( NSEvent . ModifierFlags . shift)
17051706 if theEvent. keyCode == 123 { self . moveSelectionLeft ( extend) }
17061707 else if theEvent. keyCode == 124 { self . moveSelectionRight ( extend) }
17071708 else if theEvent. keyCode == 125 { self . moveSelectionDown ( extend) }
@@ -2562,7 +2563,7 @@ open class CollectionView : ScrollView, NSDraggingSource {
25622563
25632564// image = NSImage(data: cell.dataWithPDF(inside: cell.bounds))
25642565 }
2565- let comp = NSDraggingImageComponent ( key: NSDraggingImageComponentIconKey )
2566+ let comp = NSDraggingImageComponent ( key: NSDraggingItem . ImageComponentKey . icon )
25662567 comp. contents = image
25672568 comp. frame = CGRect ( origin: CGPoint . zero, size: frame. size)
25682569 return [ comp]
@@ -2623,7 +2624,7 @@ open class CollectionView : ScrollView, NSDraggingSource {
26232624 invalidateAutoscroll ( )
26242625 self . interactionDelegate? . collectionView ? ( self , dragExited: sender)
26252626 }
2626- open override func draggingEnded( _ sender: NSDraggingInfo ? ) {
2627+ open override func draggingEnded( _ sender: NSDraggingInfo ) {
26272628 self . interactionDelegate? . collectionView ? ( self , dragEnded: sender)
26282629 }
26292630 open override func draggingUpdated( _ sender: NSDraggingInfo ) -> NSDragOperation {
@@ -2651,7 +2652,7 @@ open class CollectionView : ScrollView, NSDraggingSource {
26512652 autoscrollTimer = nil
26522653 }
26532654
2654- func autoscrollTimer( _ sender: Timer ) {
2655+ @ objc func autoscrollTimer( _ sender: Timer ) {
26552656 if let p = ( sender. userInfo as? [ String : Any ] ) ? [ " point " ] as? CGPoint {
26562657 autoScroll ( to: p)
26572658 }
0 commit comments