views:

91

answers:

2

I am building a dynamic form in a Cocoa application and am planning to use the NSForm object to add entries to it from an array.

Some of the entries require a text input, but some require a boolean input (i.e. a dropdown list), and some even require a file input (i.e. a place to upload an image or a movie or sound file).

It seems that an NSFormCell is only equipped to handle text. My question is: Should I subclass NSFormCell and if so, what would be the best way to do this? Are there any better ways to do this?

Thank you for any help you can offer!

+2  A: 

You might want to look into using an NSMatrix instead. From the NSForm documentation, NSForm is simply a subclass of NSMatrix with some convenience methods geared specifically towards creating a text form in a certain configuration.

NSMatrix will let you use any cell you want for any cell (using the putCell:atRow:column: method). Thus, you could have a two-column matrix, with the left column being composed entirely of text cells, and the right column being whatever type of cell you want.

Matt Ball
Thank you. This is exactly what I was trying to find out.
jeffp
Do you know of a way to get a plain NSMatrix object in Interface Builder? I am thinking I could the Radio Group object and just add my own content. Is it better to do it this way, or to init a new NSMatrix each time this form loads?
jeffp
+2  A: 

As I haven't dealt much with NSForm myself (and haven't heard of NSFormCell before), I would personally use an NSMatrix for this task, adding the appropriate cells (NSTextFieldCell, NSButtonCell, NSPopUpButtonCell, etc) where necessary. Though I've not done this exactly in the same way as you describe before, I'm sure it should work.

-Steven Degutis

Edit: My goodness, looks like Matt Ball beat me to it. Thanks, Stackoverflow.com's-3-minute-limit-for-newbs! :D

Steven Degutis
Thank you for answering!
jeffp