Search code examples
macoscocoaswiftgrid-layoutnscollectionview

NSCollectionView any good for custom drag'n'drop grids?


I'm experimenting with NSCollectionView after doing some practicing with UICollectionView for iOS. I'm planning to write an app which central part is a flexible grid view on that cards can be dragged around freely and I want to start with a OSX version first before tackling a iOS version.

The UICollectionView seemed like a good choice for my purpose so far (with a custom UICollectionViewLayout anyway) but now that I'm getting to know NSCollectionView for Cocoa on OSX this class seems rather meagre since there doesn't seem to be a comparable NSCollectionViewLayout class and in-depth info or tutorials on the web seem really sparsely seeded.

So is the NSCollectionView class actually a recommended choice at all for what I need? Or could anyone recommend me a better approach to get started going the right way with this?

(What I need is a performant, scrollable view with rows and columns onto that sub views can be dragged and dropped around freely.)


Solution

  • I agree, not recommended. NSCollectionView performance is bad.

    NSArrayController is an enigma also. That said, there was a old example of someone rolling their own, which is good sample code to peruse. ... google "TigerCollectionView".

    Your going to run into issues with every user interaction... drag, drop, insert, deferred layout, reload, etc. Better to roll your own using arrays of dictionaries, so you can see whats going on.