For example, in C# I have
[MonoPInvokeCallback(typeof(PointDelegate))]
public static void Callback(int x, int y)
{ .... }
This method is stored in a delegate of signature return void (int, int).
public delegate void PointDelegate(int x, int y);
I sent this delegate variable to Objective-C and over there I was able to call it directly to invoke Callback()
. It just works. (I have declared the equivalent typedef
at Objective-C side to match)
C#
objC(Callback);
Objective-C
typedef void (*PointDelegate)(int x, int y);
void objC(PointDelegate delegateFromCSharp)
{
delegateFromCSharp(1,2);
}
What is the equivalent in Java? Assuming I can call a method in Java already and the delegate is being passed as the only parameter, what would be the signature of that Java method? And how to invoke the received delegate?