简体   繁体   English

方法不能是 @objc 协议的成员,因为它的结果类型不能在 Objective-C 中表示

[英]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.

相关问题 方法不能标记为@objc,因为其结果类型无法在Objective-C中表示 - Method cannot be marked @objc because its result type cannot be represented in Objective-C 属性不能被标记为@objc,因为它的类型不能在 Objective-C 中表示 - Property cannot be marked @objc because its type cannot be represented in Objective-C Swift 5 方法不能标记为@objc 因为参数2的类型不能在Objective-C中表示 - Swift 5 Method cannot be marked @objc because the type of the parameter 2 cannot be represented in Objective-C Method cannot be marked @objc because the type of parameter 3 cannot be represented in Objective-C - @objc func 中无法识别错误类型? - Method cannot be marked @objc because the type of the parameter 3 cannot be represented in Objective-C - Error type not recognized in @objc func? 属性无法标记为@NSManaged,因为其类型无法在Objective-C中表示 - Property cannot be marked @NSManaged because its type cannot be represented in Objective-C 抛出方法不能是@objc协议的成员,因为它返回类型'Bool'的值 - Throwing method cannot be a member of an @objc protocol because it returns a value of type 'Bool' 迅速不符合Objective-C协议 - Cannot conform to objective-c protocol in swift 使用字典时,方法不能为@objc协议的成员 - Method cannot be a member of an @objc protocol while using Dictionary Swift @objc 协议不能用作符合协议 'Equatable' 的类型,因为 'Equatable' 有静态要求 - Swift @objc protocol cannot be used as a type conforming to protocol 'Equatable' because 'Equatable' has static requirements Objective-C运行时:声明类型为Class(objc_class)的变量符合协议意味着什么? - Objective-C runtime: What does declaring a variable of type Class (objc_class) conforming to a protocol mean?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM