我试图将 Java 可空性注释转换为 Objective-C 以在 Swift 中获取可选值,但没有任何反应,方法的签名保持不变。
这是Java代码:
import javax.annotation.Nullable;
import com.google.j2objc.annotations.ObjectiveCName;
public class UserValidation {
@Nullable
@ObjectiveCName(value = "getFormattedUserId:")
public static String getFormattedUserId(@Nullable String userId) {}
}
翻译后我得到:
+ (NSString *)getFormattedUserId:(NSString *)userId;
而不是:
+ (NSString * __nullable)getFormattedUserId:(NSString * __nullable)userId;
我想要这个签名罪 Swift:
class func getFormattedUserId(userId: String?) -> String?
我做错了什么?
非常感谢。
最佳答案
关于java - J2ObjC:将 @Nullable 转换为 __nullable,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34724915/