Tell me the difference between NSOutlineView and view based NSTableview as I know view based table view may not contain tree controller and NSOutlineView can have tree controller object
is it true or wrong
Apple says it best:
NSOutlineView is a subclass of NSTableView that lets the user expand
or collapse rows that contain hierarchical data. As in a table view,
an outline view displays data for a set of related items, with rows
representing individual items and columns representing the attributes
of those items. Unlike a table view, items in an outline view are not
in a flat list, but rather may be organized in a hierarchy, like files
and folders on a hard drive, or managers and employees in an
organization.
So, yes, what you say is true.
Related
There are many outline items (menus) and many views and forms in the current running system.
The view is actually the same content, but the conditions are different.
Is there a way to have only one view and set conditions in the outer frame to display the content of the view?
for example:
There are 3 outer frame items (menu), click any outer frame item, a view will be displayed.
Menu 1 will open the view sorted by name
Menu 2 will open the view sorted by serial number
Menu 3 will open the view sorted by date
The views are all the same content, but different sorting methods are set to display.
As in the example, because there are 3 sorting methods, there are 3 views.
Is there a way to become only one view?
You can't control sorting. If you look at the NotesUIView class, you'll see there are no methods available for that. There's not much available there at all.
The only way you can control a view from code outside the view is by embedding it in a form, subform, or page, and using the Show Single Category feature.
I have a main NSArrayController bound to an NSTableView with each row containing an instance of MyObject. MyObject has about 30 properties, but the NSTableView only has 5 columns (to show the most important properties). When a row (or more) is selected I have another NSTableView (a detail view) which shows all the properties, one per row. The detail table has two columns, one for the property name and one for the property value.
I have this working right now but my detail NSTableView uses a data source rather than bindings. This works fine as long as I notify my detail controller (which manages the data source) of a change in the main selection so that it can reload the detail table.
While it is easy to detect a change in selection, it is harder to detect a change in one of the properties of a selected object. I see elsewhere on StackOverflow, that one way to do this is to have a dummy property and use keyPathsForValuesAffectingValueForKey. Does this work well performance-wise?
Is there some other/better way to build my detail NSTableView/NSArrayController so that each row represents one property of the selected objects on the main NSTableView/NSArrayController? I'd like to use bindings if possible.
im a osx-dev noob that is trying to build an application with three table views that will show the content of a core data store entity. But each table view is filtered on the attribute "status" of the entity.
the problem occurs when i also want to show the selected entity in textfields. I'm using three different array controllers with different fetch predicates. But in a textfield i can only bind the value to one array controller.
should i ditch the bindings and do it all programaticly or is there a simple solution to this? :)
here is an screenshot so you can grasp my app description.
Keep bindings to populate the text fields if it satisfies what you want to do with this GUI. I'd add an NSObjectController to control the one entity those fields represent. If you want the user's changes to those fields persisted, bindings are still awesome.
But I think with three tables that might control what's displayed in the text fields, you're going to need to have some sort of non-binding glue code that determines which of the tables wins. You can probably do everything you want by implementing some of the NSTableViewDelegate protocol.
If the text fields should display the last entity that the user clicked in any of the tables, simply have each table call the same tableViewSelectionDidChange delegate function. All three tables could have the same delegate. You can then call setContent on the NSObjectController from that function.
You could also use similar glue code to prevent more than one selection in any of the three tables, by having the same delegate function deselect everything in the other tables either through the view or the controller. But that's up to you and needs consideration of whether you want multiple selection, etc.
I have inspector view and because it contains a lot of UI I want to explore cocoa bindings to connect it to the model. The inspector view will update depending on the currently selected object in an outline view and the inspector view displays controls to alter properties (like colour, name, shape etc.) that can be changed.
This works well when only one row in the outline view is selected because the view has a one-to-one relationship with the model object. However, there are two special cases that I want to be able to catch:
Empty selection
If no items in the outline view are selected I want to display a special "No items selected view" placeholder view.
Multiple selection
If multiple items are selected I can either display a "Multiple items selected view" placeholder view or I can decide to let the changes apply globally to all selected model objects.
My question is how can these special cases be caught when using bindings? Moreover, how can I do behaviour "A" when there is an empty selection and behaviour "B" when there is a multiple section. This sort of thing is trivial when using target/action because you can just code the logic into the action method.
Bindings seem great when propagating changes to values but I'm unsure how to go about implementing bindings that require different decisions based on current selection state.
Is there any way how i can maintain my own data model of selected items in a NSTableView.
I find it either pretty slow or complicated to keep the state of selected items when i update the table model.
You can maintain your own NSMutableIndexSet for the selected row indexes. If you're binding the table view's columns to an array controller's arrangedObjects and the array controller's contentArray to an array you own, bind the array controller's selectedIndexes to your index set. If you're implementing a data source, be the view's delegate as well and implement the delegate methods relevant to managing the selection.