복붙노트

[SWIFT] 폐쇄 인수 목록에 대한 콘텐츠 유형 1 개 인수를 예상하고 있지만, 4는 지정된

SWIFT

폐쇄 인수 목록에 대한 콘텐츠 유형 1 개 인수를 예상하고 있지만, 4는 지정된

해결법


  1. 1.코드가 더 같이해야하므로 폐쇄 형 응답 의 단일 매개 변수를 취합니다.

    코드가 더 같이해야하므로 폐쇄 형 응답 의 단일 매개 변수를 취합니다.

    Alamofire.request(.POST, urlString, parameters: parameters).responseJSON { response in
        let json = JSON(response.data!)
        let token = json["token"].string
        response(token: token)
    }
    

  2. 2.도움을 주셔서 감사합니다,이 내 처음으로 여기에 요청했다 그것은 도움과 격려했다. 최종 코드는 다음과 같습니다 :

    도움을 주셔서 감사합니다,이 내 처음으로 여기에 요청했다 그것은 도움과 격려했다. 최종 코드는 다음과 같습니다 :

        static func loginWithEmail(email: String, password: String, func_response: (token: String?) -> ()) {
        let urlString = baseURL + ResourcePath.login.description
        let parameters = [
            "email": email,
            "password": password
        ]
        Alamofire.request(.POST, urlString, parameters: parameters).responseJSON { response in
            if response.result.isSuccess {
                let json = JSON(response.result.value!)
                let token = json["token"].string
                func_response(token: token)
            }
        }
    
  3. from https://stackoverflow.com/questions/33384342/contextual-type-for-closure-argument-list-expects-1-argument-but-4-were-specifi by cc-by-sa and MIT license