views:

19

answers:

1

I'm writing a GUI for MongoDB using Cocoa. It's going well, but I don't know how to make KVO properties that would be lazily loaded. How does one handle that?

For instance, viewing the documents in a Mongo collection. The collection might have a million items in it. I suspect I shouldn't be downloading the full 2-5 GiB of data to my Cocoa app, then format and display 20 rows. How does one implement that?

I called my project Mongo Explorer, available on GitHub. Specifically, how would I code MECollection#reload to be lazy? Do I need to implement a data source delegate for my NSTableView?

A: 

You could manage lazy loading either in an NSArrayController subclass or by implementing the NSTableView data source delegate. The former is more general (you could use it for other view types), but the later is probably easier.

Barry Wark
I'll go with the data source delegate. As you said, it's much easier.
François Beausoleil