Hi All
I am using https://material.io/develop/ios/components/snackbars/api-docs/Classes/MDCSnackbarManager.html in my project. The java code generated for this has static method as follows.
@Generated
@Selector("setDelegate:")
public static native void setDelegate_unsafe(
@Mapped(ObjCObjectMapper.class) MDCSnackbarManagerDelegate value);
@Generated
public static void setDelegate(
@Mapped(ObjCObjectMapper.class) MDCSnackbarManagerDelegate value) {
Object __old = delegate();
if (value != null) {
org.moe.natj.objc.ObjCRuntime.associateObjCObject(this, value);
}
setDelegate_unsafe(value);
if (__old != null) {
org.moe.natj.objc.ObjCRuntime.dissociateObjCObject(this, __old);
}
}
This static method makes use of “this”, which cannot be used in static context.
The ObjC definition is as follows.
@implementation MDCSnackbarManager
+ (void)setDelegate:(id<MDCSnackbarManagerDelegate>)delegate {
MDCSnackbarManagerInternal *manager = [MDCSnackbarManagerInternal sharedInstance];
manager.delegate = delegate;
}
@end
Is this a bug ?
To overcome this I have created an instance variable of type MDCSnackbarManager as follows
private static final MDCSnackbarManager _this = MDCSnackbarManager.alloc().init();
and I am using this “_this” in place of generated “this”.
Just wanted inputs the work around is fine.
Regards.
On version 1.4.2