Behaviour Change in dragging NSCollectionViewItem

Harry Ng
macOS App Development
1 min readOct 13, 2016

Since official launch of macOS Sierra in September, more users are updating to the latest operating system. This is both good and bad news to developers. The goods news is new APIs, even it is not much in this version. The bad news is to face undocumented behaviour changes.

While I am a heavy user on NSCollectionView, I saw some changes without documentation. This time I want to talk about Drag & Drop.

Dragging NSCollectionViewItem

I have some app-specific workflows depending on NSCollectionView APIs. In updating to Sierra, I noticed that deselectItemsAtIndexPaths(_:) Swift 2.3 or deselectItems(at:) in Swift 3 is not called after dropping the item.

As a result, Sierra keeps the current NSIndexPath in selectionIndexPaths selectionIndexPaths. In order to keep the same behaviour across operating system versions, I shall deselect the item programmatically. Notice that manually deselecting items will not call the delegate methods.

--

--