调用中的额外参数“移动号码”

问题描述 投票:0回答:1

我已经坐了一会儿这个错误,我甚至检查堆栈溢出类似的问题,但没有帮助。我收到这个错误,我不知道我做错了什么。

这是错误图像,由于我不能发布它的点少,但我可以嵌入这个链接。 qazxsw poi

这是我发生错误的代码:

This is the eror image, due to less points i cant post it but i can embed a this 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!)
        }
    }
....
ios swift mode
1个回答
1
投票

嗯,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
© www.soinside.com 2019 - 2024. All rights reserved.