Array Controller's Selection - Array if more than one else dictionary

I have a Array Controller supplying to a table view.
I’ve have a separate “detail view” that will show more info about the selection
when it is selected in the table.

I bound text fields to the various key paths I needed.
and had an additional smaller table that displayed another sub-array of items.
Again all via Interface Builder.

Recently I’ve now been playing with PaintCode and trying to build a better looking
interface and with their variable system I’ve finding it quite handy to be able to
place different element on the screen based on changes in variables (dictionary values).

What sucked was not being able to bind these either graphically in IB or via
the bindings panel. And having to programmatically set up a whole bunch
of code. Well it was a good learning experience and I’ve learned about view controllers.

ISSUE:

  • arrayVariable = controller valueForKeyPath:@“selection.keyName”
  • the selected item in the table can contain from 0-8 keyName items
    each of them are a dictionary with another 8 key-value pairs.
  • I will then iterate over the array and pull out values from each dictionary
  • the issue that comes up is that when I go to iterate over the array but it only contains
    one item. It is logged as being a dictionary instead.
  • I’ve figured out how to get around this by checking the arrayVariables class
    and if it’s a NSDictionary then I add it as an object to a new array.
    If it’s already an array then I copy it to the new array.

Any ideas on how to get around this?

  1. changing the KeyPath: “Selected Objects” tried? didn’t work
  2. thru other earlier table programming I was reading something about having
    a set or Indexed Set returned from the selection instead.
  3. changing the way I’m accessing it from the controller?
    In other methods I would have used objectForKey, but won’t allow me
    to access the selection of the controller?

any insight would be greatly appreciated.

thanks

The two possibilities are selectionIndexes or selectedObjects.