-1
스위프트 3에서 고정 방법에 폐쇄 유형을 오버로드 할 수 있습니까? 예를 들어, 나는이 방법으로 구조체가 :Swift 3에서 클로저 시그니처로 정적 메서드에 과부하를 걸 수 있습니까?
struct Some {
static func doSomething(first: String, @escaping completion: ([Int]?) -> Void) {
...
}
static func doSomething(first: String, @escaping completion: ([Int]?, String?) -> Void) {
...
}
}
을하지만 난이 (한 매개 변수를 사용하여 클로저) 첫 번째 방법 Some.doSomething(first: "Hello") { (numbers) in ... }
를 호출 할 때 컴파일러는 나에게 오류 제공 :
Ambiguous use of 'doSomething(first:completion:)'
나는 competip 매개 변수를 지정하는 것이 좋습니다. Some.doSomething (first : "Hello") {(numbers : [Int]?) -> Void in ...} – Bruce0
@ Bruce0 네, 효과가있었습니다. 도와 줘서 고마워! – Dmitrue