NSOutlineView from Java solved?
NSOutlineView from Java solved?
- Subject: NSOutlineView from Java solved?
- From: "Doug Knowles \(PB\)" <email@hidden>
- Date: Thu, 12 Jul 2001 10:44:25 -0400
I may have overcome the previously discussed problem of NSOutlineView losing
track of Java objects.
Briefly, instead of passing Java objects (such as String's, which I had been
using) out of my DataSource's outlineViewChildOfItem() method (for example), I
instantiate Objective-C objects as proxies of the Java objects I would
otherwise pass to NSOutlineView. The rationale is that the Obj-C runtime will
retain objects created from Java code, satisfying the dictum that the
DataSource is obliged to retain the objects.
I'm still refining my solution, but here are some of the details:
- It seems to be acceptable to simply construct a unique NSObject() for each
item to be represented in the NSOutlineView. I originally used an
NSMutableString to contain an identification string for the "real" object, but
it proved easier to use content-free NSObjects and maintain a Hashtable to
associate them with the original Java objects on subsequent calls into my
DataSource.
- The Java Hashtable seems to be sufficient to maintain references to the
NSObjects (and thus "retain" them). Initially I was adding them to an
Objective-C container (NSMutableArray), but I backed out the use of this
container and everything still appears to work.
That's the gist of it. I'm not ready to share source yet, because my
implementation has become badly butchered by trial-and-error programming.
Doug K;