[英]Method cannot be a member of an @objc protocol because its result type cannot be represented in Objective-C
I am getting "Method cannot be a member of an @objc protocol because its result type cannot be represented in Objective-C" error while making this method我在创建此方法时收到“方法不能成为 @objc 协议的成员,因为它的结果类型无法在 Objective-C 中表示”错误
@objc public protocol ShareSecurityQuestionProtocol {
func setResultofSecurityQuestion(valueSent: [NSMutableDictionary]) -> (success: Bool, error: NSString)
}
Tuples cannot be represented in Obj-C, so you cannot make your function return a tuple.元组不能在 Obj-C 中表示,所以你不能让你的 function 返回一个元组。 Create an Obj-C type that holds both fields you want to return and return that type instead of a tuple.创建一个 Obj-C 类型,该类型包含您要返回的两个字段并返回该类型而不是元组。
@objc public class ShareSecurityQuestionResult: NSObject {
let success: Bool
let error: String
init(success: Bool, error: String) {
self.success = success
self.error = error
}
}
@objc public protocol ShareSecurityQuestionProtocol {
func setResultofSecurityQuestion(valueSent: [NSMutableDictionary]) -> ShareSecurityQuestionResult
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.