Take a look at http://jnidirect.org/examples.html for examples of
accessing ObjC via C calling convention. You ought to be able to use
the same methods using JNA (or JNIDirect may suit your needs).
Please feel free to post an example once you get it working, I can
add it to the contrib area.
On Nov 13, 2007, at 7:10 PM, Duncan McGregor wrote:
Hi, I'm hoping that some Mac guru can help out.
I'd like to wrap some Cocoa on the Mac. In order to do this I need
to create NSString objects, passing them as id (int or long I
guess) through JNA.
The function to create an NSString from a C string is
NSString::stringWithUTF8String:(const char *). This is a static
method on NSString, defined in NSString.h and hence linked from
Foundation.Framework
I'd like to persuade the following to work
public interface Foundation extends Library {
Foundation instance = (Foundation) Native.loadLibrary
("Foundation", Foundation.class);
int stringWithUTF8String(String string);
}
While I can call plain C functions in Foundation, attempting to
call stringWithUTF8String gives
java.lang.UnsatisfiedLinkError: Cannot locate function
'stringWithUTF8String'
at com.sun.jna.NativeLibrary.getFunctionAddress(NativeLibrary.java:
228)
Am I being optimistic in hoping that, as stringWithUTF8String is
static in NSString, that some naming convention will allow me to
access it without dropping down into the JNI code that we're all
here to avoid?
Thanks in anticipation