如我們所知,Swift
語言允許函數重載,在Objective-c
中重載是不合法的。Swift Overloading問題
所以我測試在我的演示項目:
import UIKit
class FuncOverLoad: NSObject {
func helloFuc (_ what:String) {
}
func helloFuc (_ what:Int) {
}
func helloFuc() -> String {
return "one"
}
func helloFuc() -> Int {
return 1
}
}
但是,爲什麼總會有錯誤:
Method ‘helloFuc’ with Objective-C selector ‘helloFunc:’ conflicts with previous declaration with the same Objective-C selector
我拍照:
爲什麼來這個問題,如果Swift
函數重載是合法的?
這是這個問題的重複。一個更好的將是http://stackoverflow.com/questions/29457720/compiler-error-method-with-objective-c-selector-conflicts-with-previous-declara?s=1|6.5289 – rmaddy