Help needed with orientation to bindings
Help needed with orientation to bindings
- Subject: Help needed with orientation to bindings
- From: Graham Cox <email@hidden>
- Date: Mon, 21 Sep 2009 22:20:22 +1000
Hi all,
So far I haven't used bindings to any serious extent, but I thought it
was about time I got with the program.
As luck would have it, one of my interfaces is showing some slightly
buggy behaviour, so I thought it might be an opportunity to replace
its implementation with a bindings-based one, as a learning exercise.
Since this seemed a straightforward application, initially it seemed
an ideal choice to start with.
Unfortunately, I've already got my head tangled up in trying to
understand the "big picture". I'm hoping someone can help me
disentangle. I'm pretty comfortable with KVC, KVO and the basics of
what bindings are, the problem is knowing exactly what I need to apply
it to my situation.
So, I have objects that can be selected. None, one or many objects
might be in the selection. The current selection is available as an
array property in the base controller (NSWindowController subclass) of
this particular UI. Each selected object has a dictionary of
associated data. It is this data I wish to edit via a table view with
columns for keys and values. This seems like a perfect fit for
NSDictionaryController. Where I'm having trouble is understanding how
to deal with multiple selections (that is, multiple dictionaries
presented by the main selection, not multiple selections in the table
view - in fact the table view selection is largely unused). If there
is a single selection, all well and good - looks like
NSDictionaryController is a good fit out of the box. But for multiple
selections, I'm less clear. I do need to be able to present in the UI
effectively a merger of all the selected dictionaries, with all keys
shown across the selection. Where multiple objects have the same key,
this is one table row, either showing <multiple values> in the value
column for that row, or the value if it's the same for all objects.
Editing the value sets the values against that key for all objects,
including adding that key/value to dictionaries for selected objects
that currently lack it. I'm sort of thinking that I need two
controllers, a bit like the Attacker/Weapon example in the
documentation - but I can't be sure because not enough stuff is clear
in my head, and besides, all the actual selection code is handled
externally - I just have a -selection property returning the objects.
If I can progress on the first part, the next problem is representing
the data type of the key/value pair. A given key will be associated
with a definite data type - string, integer, real or boolean value.
Ideally I'd like to add the appropriate cell type to the table row for
the 'type' column. My current classically implemented UI doesn't do
this at all, so this would be a new feature. It's very similar to the
tables displayed by the plist editor application. Looking at
NSDictionaryController it seems as if the only thing I can do for
added values is set a string using -setInitialValue:, so I'm not sure
how to handle the different data types.
Can anyone point me where I need to be pointed?
--Graham
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden