Observing 'many' managed objects in custom view

  • I'd like my custom view, not an NSTableView, to display many objects
    of a Core Data entity, filtered and sorted.  I've got it 90% working,
    but the difficulty I'm having with the last few issues makes me think
    that maybe my whole approach is wrong.  My custom view does not have
    any exposed bindings, so I observe using KVO.  (The NSArrayController/
    NSManagedObjectContext binding is read-only anyhow.)

    1.  Should/Must I have an NSArrayController?  Only NSObjectController
    and its subclass NSArrayController seem to have the capability of
    operating in "Entity" mode and binding to an NSManagedObjectContext.
    In the Cocoa Bindings Reference [1], NSManagedObjectContext is not
    even listed.  Yet, in Interface Builder, NSObject/ArrayController
    can, via my App_Delegate, bind to it (although in [1] this is called
    "register").  Are there any examples of viewing the "many" managed
    objects of a given entity in a moc without an NSArrayController?

    2.  Can I use the filtering and sorting capabilities of the array
    controller?  Seems wasteful not to, but...

    3.  If so, what key in the array controller can I observe?  Issues:
    'content' seems to be the only key that is KVC, but it does not
    change and therefore does not send observeValueForKeyPath:::: when
    object property changes cause a change in the sorted/filtered
    output.  arrangedObjects seems to mostly work but is not KVC (i.e.
    there is no -setArrangedObjects method).  Is that OK, since I'm only

    4.  What is the underlying problem with my approach which is causing
    these (and a few other) headaches?


    Jerry Krinock

    [1] http://developer.apple.com/documentation/Cocoa/Reference/
  • On Sep 29, 2007, at 5:18 PM, Jerry Krinock wrote:

    > [...]

    As ever, Core Data and bindings are largely orthogonal.
    There's little reason not to use the array controllers for doing what
    they're designed to do.  Just about everything from the Graphics
    Bindings example at <http://homepage.mac.com/mmalc/CocoaExamples/controllers.html> applies...

previous month september 2007 next month
          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