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

标签 objective-c swift xcode xcode10.2

我今天将 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/

相关文章:

objective-c - 滚动 MKMapView 时淡出弹出窗口

ios - 带有顶角、边框和阴影的聊天项目 View

ios - UIActivityIndi​​catorView 为零?

ios - 向 Xcode 添加了单元测试目标 - 导入桥接 header 失败不会消失

objective-c - 为什么我们必须使用@synthesize 有实际原因吗?

iphone - 在 UIImageView 中使用标准 iOS 图像?

ios - ADBannerView 困惑(iOS 8)

swift - 将附件添加到主页总是返回错误(GenericError)

objective-c - OpenGL ES 不会绘制

iOS - 通过单例实现连接到服务器