2016-10-21 3 views
0

"모호한 사용 ... "과 중복되므로 닫지 마십시오. 강렬한 연구에도 불구하고 나는 내 문제를 해결하는 비슷한 스레드를 찾을 수 없었습니다.스위프트 3/해결 방법 : "승인 (_ : 완료 :)" "

내가 스위프트 3 프로젝트를 통해 업데이트 및 컴파일러 오류에 붙어

:

Ambiguous use of 'authorize(_:completion:)'

코드 :

func connectToInstagram() { 

    let auth: NSMutableDictionary = ["client_id": INSTAGRAM_CLIENT_ID, 
            SimpleAuthRedirectURIKey: INSTAGRAM_REDIRECT_URI] 

    SimpleAuth.configuration()["instagram"] = auth 

    SimpleAuth.authorize("instagram") { (anyObject, error) in // error here 

     if anyObject != nil {... 

SimpleAuth이 목적으로 작성된 소셜 미디어 인증을 처리 할 수있는 프레임 워크입니다 C.

SimpleAuth :

,

enter image description here

SimpleAuthRequestHandler :

public typealias SimpleAuthRequestHandler = (Any?, Error?) -> Swift.Void 

public let SimpleAuthPresentInterfaceBlockKey: String 
public let SimpleAuthDismissInterfaceBlockKey: String 
I가 줄을 변경하는 것을 시도했다

enter image description here

: 예상대로

_ = SimpleAuth.authorize("instagram") { (anyObject: Any?, error: Error?) in 

_ = SimpleAuth.authorize("instagram", completion: { (anyObject: Any?, error: Error?) in 

그러나, 그것은 변화하지 않았다 아무것도 . 내가 뭘 놓치고 있니? 도움말은 매우 감사하겠습니다.

빌드 로그 :

enter image description here

xy/InstagramVC.swift:409:9: error: ambiguous use of 'authorize(_:completion:)' 
     SimpleAuth.authorize("instagram") { (any: Any?, error: Error?) -> Swift.Void in 
     ^
SimpleAuth.SimpleAuth:24:21: note: found this candidate 
    open class func authorize(_ provider: String!, completion: SimpleAuth.SimpleAuthRequestHandler!) 
        ^
SimpleAuth.SimpleAuth:34:21: note: found this candidate 
    open class func authorize(_ provider: String!, options: [AnyHashable : Any]! = [:], completion: SimpleAuth.SimpleAuthRequestHandler!) 
+0

빌드 로그를 확인하거나 명령 줄에서 빌드하십시오. 내가 아는 한 컴파일러는 모호성을 유발하는 범죄자 목록을 제공 할 수 있습니다. – courteouselk

+0

@AntonBronnikov 빌드 로그 정보로 질문을 편집했습니다. –

+0

제가 틀렸다면 정정하십시오. 그러나 두 가지 방법이 모호합니다 ('options' 인수가있는 값은 기본값을 갖기 때문에 줄일 수 있습니다). 다른 하나와 정확히 같은 서명으로).디폴트 값 (이 비트는'= [:]')을 제거하려고 시도합니다. – courteouselk

답변

1

문제는 API를이다. 그들은이 두 가지 기능 제공 :

open class func authorize(_ provider: String!, completion: SimpleAuth.SimpleAuthRequestHandler!)

open class func authorize(_ provider: String!, options: [AnyHashable : Any]! = [:], completion: SimpleAuth.SimpleAuthRequestHandler!)

을하지만, 당신이 볼 수있는 두 번째 함수의 options 인수는 기본 인자 ( [:])를 받고있다. 따라서 매개 변수를 지정하지 않으면 options 매개 변수를 지정하면 컴파일러에서 호출 할 함수를 알 수 없습니다.

이것은 첫 번째 기능을 사용할 수 없음을 의미합니다. 항상 두 번째 함수를 사용하고 명시적인 options 인수를 전달해야합니다. 그래서 :

authorize("instagram", options: [:]) { (any: Any?, error: Error?) -> Void in ... }

그것은 SimpleAuth 프레임 워크 개발자와 버그를 신고 아마 가치가있다.