NSSelector.invoke() across bridge
NSSelector.invoke() across bridge
- Subject: NSSelector.invoke() across bridge
- From: email@hidden
- Date: Wed, 21 Aug 2002 10:45:41 -0700
I've got a Cocoa app I'm working on that blends Obj-C and Java. The
majority of my code is in Obj-C, but I need to make use of one Java
library (JAR) and so am relying a bit of bridge code to bring this all
together. I figured life would have been much more difficult for me to
work the other way (primarily Java with a sprinkling of Obj-C).
Anyway... I'm at a sticking point with achieving the equivalent of
performSelector from the Java side. Basically, I've got an NSObject on
the Java side of my bridge that represents a real Obj-C data object.
The Obj-C class has a method "valueForProperty:(NSString *)property"
that I want to be able to invoke from the Java side. Because the method
takes an argument, I can't simply use valueForKey() and unfortunately,
the performSelector API isn't reflected in the Java foundation classes.
So...
I'm trying to make this work with NSSelector. Here's what I've got at
the moment:
NSSelector sel = new NSSelector("valueForProperty:", new Class[]
{String.class});
Object o = sel.invoke(myDataObject, "accountNumber");
This results in a "NoSuchMethod" exception which I'm assuming is due to
the fact that I can't cast the NSObject ("myDataObject") to the proper
concrete class. So... I think I've headed down the wrong path here, but
I know there's got to be a solution.
How best should I go about accessing this method in my Obj-C class from
a Java object?
Thanks for any and all advice on the topic!
Cheers,
- Eric Hanson
Incarna LLC
_______________________________________________
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.