调用中的额外参数 'mobileNumber'

Extra argument 'mobileNumber' in call

我已经为这个错误坐了一段时间,我什至检查了堆栈溢出类似的问题,但没有帮助。我收到此错误,我不知道自己做错了什么。

这是错误图片,由于点数较少我不能 post 但我可以嵌入这个 link。

这是我发生错误的代码:

class SearchViewModelFromSearchResult: SearchCustomerModel 
{

    var search: SearchResultObj?

    init() 
    {
        self.search = SearchResultObj()
    }

    func searchDataRequested(_ apiUrl: String,_ country: String,_ phone:String) 
    {

        let service = ServiceCall(urlServiceCall: apiUrl, country: country, phone: phone)
        let url = URL(string: apiUrl)
        let request = URLRequest(url: url!)
        let country = country
        let phone = phone

        service.fetchJson(request: request, customerCountry: country, mobileNumber: phone)
         { (ok, json) in
            print("CallBack response : \(String(describing: json))")
            self.jsonMappingToSearch(json!)
        }
    }
....

服务电话class:

class ServiceCall: NSObject, ServiceCallProtocol, URLSessionDelegate 
{
    let urlServiceCall: String?
    let country: String?
    let phone: String?

    init(urlServiceCall: String,country: String, phone: String)
    {
        self.urlServiceCall = urlServiceCall
        self.country = country
        self.phone = phone
    }

    func fetchJson(request: URLRequest, customerCountry: String, mobileNumber: String)
    {
        let searchParamas = CustomerSearch.init(country: customerCountry, phoneNumber: mobileNumber)
        var request = request
        request.httpMethod = "POST"
        request.httpBody = try?  searchParamas.jsonData()
        request.addValue("application/json", forHTTPHeaderField: "Content-Type")

        let session = URLSession.shared
        let task = session.dataTask(with: request, completionHandler: { data, response, error -> Void in
            do {
                let json = try JSONSerialization.jsonObject(with: data!) as! Dictionary<String, Any>
                let status = json["status"] as? Bool
                if status == true {

                }else{

                }
            } catch {
               print("Unable to make an api call")
            }
        })

        task.resume()
    }
}

嗯,fetchJson 没有完成参数,但是当你调用它时,你写:

{ (ok, json) in

请将您的函数声明更改为:

func fetchJson(request: URLRequest, customerCountry: String, mobileNumber: String, completion: ((Bool, Dictionary<String, Any>?) -> Void)?)