Re: Java Cocoa Table View DataSources
Re: Java Cocoa Table View DataSources
- Subject: Re: Java Cocoa Table View DataSources
- From: Mike Ferris <email@hidden>
- Date: Sat, 28 Dec 2002 12:05:02 -0800
Welcome to the impedance mismatch between reference counting and
garbage collection.
A table's dataSource is a weak reference. The table does not retain
it. For various extremely subtle and obscure reasons deep in the Java
bridge, this means that if your pure Java dataSource is not retained by
some other Obj-C object, it will ultimately be collected and disappear
(actually it is the Obj-C proxy to the Java object that disappears).
The easiest thing to do is to simply shove the dataSource into an
NSArray that you keep around.
Nasty and brutish, but there it it is.
Mike
Begin forwarded message:
From: Niko Matsakis <email@hidden>
Date: Sat Dec 28, 2002 11:48:14 AM US/Pacific
To: email@hidden
Subject: Java Cocoa Table View DataSources
I'm having some trouble with cocoa table view datasources. When I call
"mTableView.setDataSource (new ListSource (stringarray))", it seems to
work
for a while but eventually crashes.
If there is a better place to go for help with Java Cocoa, let me
know. I've
got some other questions about dynamically generating the widgets in
the
window.
Here is the data view class:
//
// ListSource.java
// flash
//
// Created by Niko Matsakis on Wed Dec 25 2002.
//
import com.apple.cocoa.foundation.*;
import com.apple.cocoa.application.*;
public class ListSource {
protected String[] mData;
public ListSource (String[] data) {
mData = data;
}
public int numberOfRowsInTableView (NSTableView view) {
return mData.length;
}
public Object tableViewObjectValueForLocation(NSTableView v,
NSTableColumn c, int idx) {
return mData[idx];
}
}
niko
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.