Hello,
I am new to Multi-OS engine (and Objective-C) and have run into some problems.
I have created a protocol in Objective-C which I want to implement as a java interface and use as a callback to call java code from the Objective-C code.
I used the plugin to generate java-bindings from my header file. The bindings works fine in the java -> Objective-C direction (I can create Objective-C objects and call functions from java) but it throws a runtime error when i implement the protocol in java, pass it to Objective-C and then call the java function from Objective-C.
Error: “unrecognized selector sent to instance”
Objective-C header file
(The space after each @ are to avoid being interpreted as mentions)
@ protocol DiscoveryManagerDelegate
- (void)onDiscover: (NSString *) str;
@ end
@ interface DiscoveryManager : NSObject
@ property(nonatomic, weak) id delegate;
- (void)startDiscovery: (NSString *) str;
@ end
Generated Java interface
@ Generated
@ Runtime(ObjCRuntime.class)
@ ObjCProtocolName(“DiscoveryManagerDelegate”)
public interface DiscoveryManagerDelegate {
@ Generated
@ Selector(“onDiscover:”)
void onDiscover(String str);
}
Java interface implementation:
public class JavaDelegate implements DiscoveryManagerDelegate {
@ Override public void onDiscover(String str) { // }
}
Java code:
DiscoveryManager manager = DiscoveryManager.alloc().init(); JavaDelegate delegate = new JavaDelegate(); manager.setDelegate(delegate); manager.startDiscovery("starting discovery");
Using:
Android Studio 2.3.3
Multi-OS engine plugin 1.3.2
Xcode 8.3.1
Any help or guidance appreciated!