Hi Erik,

NSCollectionView is great if you have it, but if you're still coding for pre-10.5 it doesn't help.

What is it that you disagree with specifically?

Before adding any rows or columns to your matrix, set it's cell class with setCellClass: or its prototype cell with – setPrototype: but don't do both.


The prototype cell was set in the initWithFrame in my example.

Before adding any rows or columns to your matrix, set it's cell class with setCellClass: or its prototype cell with – setPrototype: but don't do both.

Add rows with – addRow and add columns with -addColumn until you have enough cells for all of your data. Then loop through the rows and columns calling – cellAtRow:column: and configuring each cell based on your data.

This is what's going on in the rebuildThumbnailMatrix class I mentioned.

For all but the most simplistic of tasks, I think you'll end up subclassing NSMatrix and the cell class to customize the behavior and look. If you're talking about a matrix of buttons or static items that doesn't change or resize, fine, but anything more involved requires subclassing. Drag and Drop support alone requires an NSMatrix subclass.

If you want to deal with live resizing, you need to subclass as well. I think there are lots of reasons to work with an NSMatrix subclass. Why do you highly discourage it?

- d

On Mar 26, 2008, at 4:42 PM, Erik Buck wrote:
Wow! Dave Hersey wrote a very detailed and comprehensive post that must have taken a long time. Sadly, I disagree with almost all of it.

NSMatrix is an "older" class that predates the "data source" design pattern that emerged (i think) in NeXTstep 3.0 in about 1994 as I recall. I think NSMatrix was in Nextstep 0.8 in 1988.

I highly discourage sub-classing NSMatrix.

To use NSMatrix...
Before adding any rows or columns to your matrix, set it's cell class with setCellClass: or its prototype cell with – setPrototype: but don't do both.

Add rows with – addRow and add columns with -addColumn until you have enough cells for all of your data. Then loop through the rows and columns calling – cellAtRow:column: and configuring each cell based on your data.



The better approach is to use NSCollectionView in Leopard. 
http://developer.apple.com/documentation/Cocoa/Reference/NSCollectionView_Class/Introduction/Introduction.html

NSCollectionView is much more flexible and more supportive of MVC design using less overall code.
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to