我们知道,Swift语言允许函数重载,而在Objective-c中,重载是不合法的。
所以我在我的演示项目中进行了测试:
import UIKit
class FuncOverLoad: NSObject {
func helloFuc (_ what:String) {
}
func helloFuc (_ what:Int) {
}
func helloFuc() -> String {
return "one"
}
func helloFuc() -> Int {
return 1
}
}但是,为什么会出现这样的错误:
使用目标-C选择器‘helloFuc’的方法‘helloFunc:’与先前声明的冲突-C选择器
我拍的照片是:

如果Swift函数重载是合法的,为什么会出现这个问题?
发布于 2016-12-24 05:59:54
在您的示例中,删除: NSObject将清除错误。
https://stackoverflow.com/questions/41310744
复制相似问题