Can you populate an NSTableView with an NSEnumerator?

  • I have some data I want to display in an NSTableView, the problem is the
    dataset can be big, as in hundreds of thousands of rows.
    I have implemented a lightweight NSEnumerator that will let me iterator
    across the data without actually having to create a giant NSArray.
    I can only find documentation on populating an NSTableView with an NSArray,
    for very very very very large datasets what is the prefered idiom(s)?
  • There is no reason to use an NSArray to populate an NSTableView -- it
    can be anything you want as long as you provide the datasource
    methods. The documentation on NSTableView datasources should get you
    started.

    http://developer.apple.com/documentation/Cocoa/Reference/
    ApplicationKit/Protocols/NSTableDataSource_Protocol/Reference/
    Reference.html

    On Oct 31, 2006, at 1:58 PM, Jarrod Roberson wrote:

    > I have some data I want to display in an NSTableView, the problem
    > is the
    > dataset can be big, as in hundreds of thousands of rows.
    > I have implemented a lightweight NSEnumerator that will let me
    > iterator
    > across the data without actually having to create a giant NSArray.
    > I can only find documentation on populating an NSTableView with an
    > NSArray,
    > for very very very very large datasets what is the prefered idiom(s)?
    > _______________________________________________
    > 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/<hankh...>
    >
    > This email sent to <hankh...>
    >

    Hank Heijink
    www.hankheijink.com
    <hankh...>
  • On Oct 31, 2006, at 1:58 PM, Jarrod Roberson wrote:

    > I have some data I want to display in an NSTableView, the problem
    > is the
    > dataset can be big, as in hundreds of thousands of rows.
    > I have implemented a lightweight NSEnumerator that will let me
    > iterator
    > across the data without actually having to create a giant NSArray.
    > I can only find documentation on populating an NSTableView with an
    > NSArray,
    > for very very very very large datasets what is the prefered idiom(s)?

    It doesn't matter. Any storage mechanism will suffice, so long as it
    can quickly:

    1. Find the number of rows
    2. Fetch a field given its row and column

    The examples use NSArrays because they're as simple as a model class
    can get. The purpose of the examples is to focus on NSTableView, and
    using a more complicated model class would only serve to distract
    from that purpose.

    sherm--

    Web Hosting by West Virginians, for West Virginians: http://wv-www.net
    Cocoa programming in Perl: http://camelbones.sourceforge.net
  • On Oct 31, 2006, at 10:58 AM, Jarrod Roberson wrote:

    > I can only find documentation on populating an NSTableView with an
    > NSArray,
    > for very very very very large datasets what is the prefered idiom(s)?

    You don't need to use an NSArray, whether you're using a data source
    or bindings.

    If you're using a data source, just implement the methods to use your
    own back-end rather than to use an NSArray as a back-end.  NSTableView
    will invoke the data source methods as appropriate for the data that's
    currently displayed.

    If you're using bindings, you can bind your table's columns through a
    key that represents your underlying data, and then implement
    appropriate key-value coding indexed accessor methods for that key.
    These are methods like -countOfFoos, -objectInFoosAtIndex:, -
    getFoo:range: (if profiling shows it's necessary for performance),
    etc.  These methods can access your underlying data in any way they
    want, as long as appropriate key-value observing messages are posted
    when the underlying data changes.  Just as with a table view data
    source, the object providing this key will only be asked to provide
    data that's relevant for what's actually being displayed.

    The key point to remember is that your code doesn't populate an
    NSTableView.  Instead, an NSTableView is given a data source or has
    its columns' values bound, and the NSTableView populates itself.  In
    particular, don't think of a table view, an outline view, or any other
    control in Cocoa as "owning" the data that it contains; it doesn't.
    The data is owned by the underlying model objects, while your human
    interface is just providing a view on that data.

      -- Chris
previous month october 2006 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 31          
Go to today