objective-cmacoscocoacocoa-design-patterns

What object should implement NSCollectionViewDelegate?


I have a subclassed NSCollectionView that is created in Interface Builder and is bound to an array.

I need to implement some of the delegate classes from NSCollectionViewDelegate but I'm kind of stumped as to what class to designate as the delegate.

Do I just create a random NSObject and designate it as the delegate? Do I create an NSViewController and designate that as the delegate—but if so, since the Collection View isn't being created programmatically, how do I tie the NSViewController to the Collection View?

Any pointer to a good document that would explain stuff like this in Mac app architectural decisions would be a great bonus.


Solution

  • It is common, but not mandatory, to make a view controller also be the delegate of the underlying view object. However, you can also make a new class as you suggest and use that. If that works for your overall architecture, do that.