gpt4 book ai didi

objective-c - Xcode 10.2 Swift 错误 : Function types cannot be represented in Objective-C unless their parameters and returns can be

转载 作者:可可西里 更新时间:2023-11-01 01:07:24 27 4
gpt4 key购买 nike

我今天将 Xcode 更新到 10.2,但出现以下错误:

Method cannot be marked @objc because the type of the parameter 2 cannot be represented in Objective-C

Function types cannot be represented in Objective-C unless their parameters and returns can be I don't understand why

在 10.1 中完全没问题。这是我多年来一直使用的示例,没有任何问题。我怎样才能使这段代码无错误地编译?

@objc public func myFunction(inputString: String, handler:@escaping ((success: Bool, outPut: NSArray)) -> Void) {
// do stuff
}

最佳答案

删除短语outPut:。它总是非法的; Swift 5 终于收紧了。

所以:

@objc public func myFunction(inputString: String, handler:@escaping (NSArray) -> Void) {

关于objective-c - Xcode 10.2 Swift 错误 : Function types cannot be represented in Objective-C unless their parameters and returns can be,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55368967/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com