cells in tableview - objective-c

i need to develop table view for entering text data and boolean values, so i need to implement checkbox functionality for some tableview cells, i know how to implement regular tabledatasource interface for supply the data^ what about different types of cells? Thanks, alot.

Have you tried implementing your own UITableViewCell? You could also "manually" create one in the data source delegate but this sounds like something that could be re-usable.

There is no big difference between data types. If you are confused with C types (int, bool etc.) keep in mind that you can always wrap them with NSNumber and pass as id where needed. If the question is in cell class itself - NSButtonCell with checkbox cell is the choice. It's available in the Interface Builder.
However, I'd recommend you to use NSArrayController and bindings if it is suitable in your task. Binding is simpler way to fill the table with data and there is no need to convert c <-> obj-c data manually.

i think that what i need - tableView:dataCellForTableColumn:row:
thanks to all

Related

How to make a row in UITableView invisible?

I'm very new to this field...I'm using a UITableView to create a table in my apps..but based on some certain checks, I need to make some of the rows invisible...how can I achieve that??
To accomplish this, you simply have to change the UITableViewCell itself. But I don't really know, whether this abides by Apple's HIG (Human Interface Guidelines). Maybe you should consider to remove the cells at all and if you do need them again, add them?

Adding data to a scrollview/table

I have an NSCrollView that contains an NSTableView. It has 3 columns and 4 rows. I have 4 NSStrings with content that I need to copy into the scrollview.
Using Xcode 4 I tried connecting the table or the NSTextFieldCell and then adding the text via
[_Cell1 setStringValue:MyString];
But nothing happens. It doesn't get updated.
Any way to do this?
Thank you.
EDIT:
I found the following answer to a similar question. I still am confused but after reading Apple's example about bindings I can only say that this does not make any sense, so much code to achieve something so simple. That's the problem with everything being an object and with OOP in general.
Any simple samples out there? I don't even know how to start setting this or connecting the gazillion things you need to connect to start working with this
You should use the NSTableViewDelegate. That's a set of methods the NSTableView calls to get the data that it should display. You just have to declare the delegate object of the tableview.
Delegate Protocol
NSTableView Tutorial
Unfortunately, you can't "add" or "set" the content of a table view. Like most view objects, a table view doesn't store content; it depends on a controller to provide content when it needs it.
There are two options:
Data source: simplest, easiest to understand
Binding to an array controller: harder to understand, but less work to implement
The best Apple resource on the subject: Populating Cell-Based Table Views from the Table View Programming Guide. If you're struggling, I suggest you start with the data source option. It'll be just a few lines of code, and you can adapt the simple samples from that document.
To populate the table, you need to implement these two methods:
– numberOfRowsInTableView:
– tableView:objectValueForTableColumn:row:
And to change the data, you'll need to implement one more:
- tableView:setObjectValue:forTableColumn:row:
You'll need to set your controller as the data source for the table view in interface builder. And the correct protocol for this is NSTableViewDataSource, not NSTableViewDelegate.
You could use an NSArrayController and bind the table columns' value bindings to the array controller's arranged objects. Then add the values you want to display to the array controller.

How can I use custom sorting on an NSTableView bound to an NSArrayController?

I have an NSTableView connected to an NSArrayController by setting the column values in interface builder to the appropriate keys in the NSArrayController. I'd like to use a custom sorting order, specifically, compare:options: with NSNumericSearch. Where can I either change my code to do this, or tell interface builder to use a different comparison selector?
I'm not sure how well this would work with an ArrayController, but you might look into NSTableColumn's -setSortDescriptorPrototype: (passing your columns your own sort descriptor in code).

Problem retrieving NSCell data via [NSTableColumn dataCellForRow]

I am trying to retrieve a specific NSCell data from an NSTableView through [NSTableColumn dataCellForRow] but every time it shows different value for same row and same column. The data source remains the same at all time. The NSTableView is bound to an NSArrayController .Please if anyone can suggest a better way to do it correctly. And I don't want to implement those delegate methods. Let me know if you require more information.
Regards
Well, this is not a good idea to get data from a cell. Cells represent View concept in Model-View-Controller paradigm.
You should be able to access all the data that a cell can access, so get it from the primary data source.

How do I populate an NSPopupButton with an array of strings?

Simple question, but I am struggling a little to understand how Interface Builder interacts with the rest of the program developed in X-Code.
My UI has an NSPopupButton that I would like to fill with an array of strings that I provide. I have a controller class that defines the method to execute when the button is clicked. Is that where I would populate the NSPopupButton? It seems like I would need to initialize is somewhere, but I am confused about exactly where to do it. I know I need to use addItemsWithTitles, but where do I call that?
Assuming the list isn't changing over time, awakeFromNib (in the controller) would be a good place to populate the menu. If it's dynamic, then you'd want to populate it when the source of those strings changes.