Ijon Tichy
Ijon Tichy

Reputation: 357

What is the point of using NSTableCellView when creating view-based tables?

When you create a view-based table view in Xcode's interface builder, it automatically adds an NSTableCellView control, inside of which is an NSTextField control. You better add constraints to your text field control, otherwise it won't resize properly when you resize a column.

But it turns out that NSTableCellView controls are unnecessary. You can just use a NSTextField control, or any view that you like, in its place. And you won't need to add constraints; the control will resize automatically. So what it is the point of using an NSTableCellView control?

Upvotes: 1

Views: 340

Answers (1)

Ken Thomases
Ken Thomases

Reputation: 90601

It's for when your cells are compound views. For example, when you have an image and a text label, or more complex hierarchies.

When your cell view is a multi-view hierarchy, you need a container view. That doesn't have to be NSTableCellView, but NSTableCellView provides some nice conveniences, like an objectValue property and the outlets to the imageView and textField.

Upvotes: 2

Related Questions