NSArrayController / NSTableView questions

  • I've got an application where I want an _ordered_ list of entities on
    the many side of a one to many relationship.  The result of the
    master entity selection's entity is a set, which indicates to me the
    order is probably arbitrary (is that true?).  One solution I am
    considering is to add a numeric sorting attribute to this table, and
    to subclass the array controller to handle the
    insertObject:atArrangedObjectIndex: method.  Is this really
    necessary?  And how do I (or can I) bind an NSTableView with a
    sortDescription to express this?  Or would that be moot if I subclass
    the array controller?

    Using the result of dropping an entity into a window as an example, I
    have some questions about what is going on.  Does this "take over"
    the dataSource of the NSTableView?  What is the dataSource when this
    is happening?  The controller?  I'm trying to figure out how to
    support dragging in the NSTableView to reorder the items.  Also, I'm
    noticing the NSTableColumns are all individually bound to the various
    arrangedObject.key.path expressions.  How does this come together for
    the entire NSTableView itself, which I am noticing is not bound to
    anything?
  • On Sep 5, 2005, at 2:11 PM, Paul Forgey wrote:

    > Using the result of dropping an entity into a window as an example,
    > I have some questions about what is going on.  Does this "take
    > over" the dataSource of the NSTableView?  What is the dataSource
    > when this is happening?  The controller?  I'm trying to figure out
    > how to support dragging in the NSTableView to reorder the items.
    > Also, I'm noticing the NSTableColumns are all individually bound to
    > the various arrangedObject.key.path expressions.  How does this
    > come together for the entire NSTableView itself, which I am
    > noticing is not bound to anything?

    <http://homepage.mac.com/mmalc/CocoaExamples/controllers.html>

    mmalc
  • That answered my immediate confusions about bindings.  Thank you!

    I'd still like to know about the collections in to-many
    relationships.  Is the order preserved or is it arbitrary?

    On Sep 5, 2005, at 2:47 PM, mmalcolm crawford wrote:

    >
    > On Sep 5, 2005, at 2:11 PM, Paul Forgey wrote:
    >
    >
    >> Using the result of dropping an entity into a window as an
    >> example, I have some questions about what is going on.  Does this
    >> "take over" the dataSource of the NSTableView?  What is the
    >> dataSource when this is happening?  The controller?  I'm trying to
    >> figure out how to support dragging in the NSTableView to reorder
    >> the items.  Also, I'm noticing the NSTableColumns are all
    >> individually bound to the various arrangedObject.key.path
    >> expressions.  How does this come together for the entire
    >> NSTableView itself, which I am noticing is not bound to anything?
    >>
    >
    > <http://homepage.mac.com/mmalc/CocoaExamples/controllers.html>
    >
    > mmalc
    >
    > _______________________________________________
    > Do not post admin requests to the list. They will be ignored.
    > Cocoa-dev mailing list      (<Cocoa-dev...>)
    > Help/Unsubscribe/Update your Subscription:
    > http://lists.apple.com/mailman/options/cocoa-dev/<paulf...>
    >
    > This email sent to <paulf...>
    >
  • On Sep 5, 2005, at 3:04 PM, Paul Forgey wrote:

    > I'd still like to know about the collections in to-many
    > relationships.  Is the order preserved or is it arbitrary?

    Arbitrary (NSSet is unordered), but I won't have time to address the
    question until this evening...
    It's come up before, though, so check the archives.

    mmalc
  • In the section about how to disable all sorting in an NSTableView by
    manually binding the table view's content and selectionIndex, for
    some reason this breaks my table column using an NSPopupButtonCell.
    The contents of the popup are now apparently the description: method
    strings of the to-one entities rather than the contentValues binding
    for the column.  I get this output:
    -[NSManagedObject isEqualToString:]: selector not recognized [self =
    0x351020]

    On Sep 5, 2005, at 2:47 PM, mmalcolm crawford wrote:

    >
    > On Sep 5, 2005, at 2:11 PM, Paul Forgey wrote:
    >
    >
    >> Using the result of dropping an entity into a window as an
    >> example, I have some questions about what is going on.  Does this
    >> "take over" the dataSource of the NSTableView?  What is the
    >> dataSource when this is happening?  The controller?  I'm trying to
    >> figure out how to support dragging in the NSTableView to reorder
    >> the items.  Also, I'm noticing the NSTableColumns are all
    >> individually bound to the various arrangedObject.key.path
    >> expressions.  How does this come together for the entire
    >> NSTableView itself, which I am noticing is not bound to anything?
    >>
    >
    > <http://homepage.mac.com/mmalc/CocoaExamples/controllers.html>
    >
    > mmalc
    >
    > _______________________________________________
    > Do not post admin requests to the list. They will be ignored.
    > Cocoa-dev mailing list      (<Cocoa-dev...>)
    > Help/Unsubscribe/Update your Subscription:
    > http://lists.apple.com/mailman/options/cocoa-dev/<paulf...>
    >
    > This email sent to <paulf...>
    >
  • I also reproduced this with the ToDo sample application.  Using this
    method to disable sorting in a table view is extremely non-obvious.
    Is there an easier way to do this?

    On Sep 5, 2005, at 3:16 PM, Paul Forgey wrote:

    > In the section about how to disable all sorting in an NSTableView
    > by manually binding the table view's content and selectionIndex,
    > for some reason this breaks my table column using an
    > NSPopupButtonCell.  The contents of the popup are now apparently
    > the description: method strings of the to-one entities rather than
    > the contentValues binding for the column.  I get this output:
    > -[NSManagedObject isEqualToString:]: selector not recognized [self
    > = 0x351020]
    >
    >
  • Sorry to keep replying to myself.  I'm finally starting to understand
    this whole thing.

    [tableView unbind:@"sortDescriptors"] in my custom array controller's
    awakeFromNib (after [super awakeFromNib]) did the trick.

    Further, I implemented arrangeObjects: using my own private sort
    descriptor (since I explicitly need these contents in a strict
    order).  If I instead set the sort descriptor to be what my version
    of arrangeObjects: would do, the nature of KVO seems to hook the sort
    descriptors back up to the table view and again allows sorting on any
    of the columns.

    I'm now overriding insertObject:atArrangedObjectIndex: to take care
    of the other half.

    I know this is an unusual situation.  Normally it makes sense to
    allow the flexibility and let the arbitrary sort features do their
    job.  Maybe a worthwhile enhancement to Cocoa would be some sort of
    relationship option and corresponding controller introduced to
    provide an ordered collection.

    On Sep 5, 2005, at 5:43 PM, Paul Forgey wrote:

    > I also reproduced this with the ToDo sample application.  Using
    > this method to disable sorting in a table view is extremely non-
    > obvious.  Is there an easier way to do this?
    >
    > On Sep 5, 2005, at 3:16 PM, Paul Forgey wrote:
    >
    >
    >> In the section about how to disable all sorting in an NSTableView
    >> by manually binding the table view's content and selectionIndex,
    >> for some reason this breaks my table column using an
    >> NSPopupButtonCell.  The contents of the popup are now apparently
    >> the description: method strings of the to-one entities rather than
    >> the contentValues binding for the column.  I get this output:
    >> -[NSManagedObject isEqualToString:]: selector not recognized [self
    >> = 0x351020]
    >>
    >>
    >>
    >
    > _______________________________________________
    > Do not post admin requests to the list. They will be ignored.
    > Cocoa-dev mailing list      (<Cocoa-dev...>)
    > Help/Unsubscribe/Update your Subscription:
    > http://lists.apple.com/mailman/options/cocoa-dev/<paulf...>
    >
    > This email sent to <paulf...>
    >
previous month september 2005 next month
MTWTFSS
      1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30    
Go to today