The marshaling of blocks have changed recently in RoboVM. The author of these bindings has to update them accordingly. Here's an example (from UIApplication
) that shows how to marshal a VoidBlock
in an instance method:
private static final Selector beginBackgroundTaskWithExpirationHandler$ = Selector.register("beginBackgroundTaskWithExpirationHandler:");
@Bridge private native static int objc_beginBackgroundTask(UIApplication __self__, Selector __cmd__, ObjCBlock handler);
@Bridge private native static int objc_beginBackgroundTaskSuper(ObjCSuper __super__, Selector __cmd__, ObjCBlock handler);
public int beginBackgroundTask(VoidBlock handler) {
return beginBackgroundTask(VoidBlock.Marshaler.toObjCBlock(handler));
}
protected int beginBackgroundTask(ObjCBlock handler) {
if (customClass) { return objc_beginBackgroundTaskSuper(getSuper(), beginBackgroundTaskWithExpirationHandler$, handler); } else { return objc_beginBackgroundTask(this, beginBackgroundTaskWithExpirationHandler$, handler); }
}
And here's an example for a static method (in UIView
):
private static final Selector animateWithDuration$animations$ = Selector.register("animateWithDuration:animations:");
@Bridge private native static void objc_animate(ObjCClass __self__, Selector __cmd__, double duration, ObjCBlock animations);
public static void animate(double duration, VoidBlock animations) {
objc_animate(objCClass, animateWithDuration$animations$, duration, VoidBlock.Marshaler.toObjCBlock(animations));
}