Swift 3.0: Type of expression is ambiguous without additional context?

private func makeRequest<T where T:MappableNetwork>(method method: Alamofire.Method, url: String, parameters: [String: AnyObject]?, keyPath: String, handler: NetworkHandler<T>.handlerArray) -> Request { let headers = [ "Authorization": "", ] return Alamofire .request(method, url, parameters: parameters, encoding: .URL, headers: headers) .validate() .responseArray(keyPath: keyPath) { (response: Alamofire.Response<[T], NSError>) in if let error = response.result.error { if let data = response.data { let error = self.getError(data) if error != nil { handler(.Error(error: error!)) return } } handler(.Error(error: error)) } else if let objects = response.result.value { handler(.Success(data: objects)) } } } 

I converted the swift 2.x code to 3.x and I get an error. The type of expression is ambiguous without additional context.

enter image description here

+5
source share
1 answer

The error you indicated indicates that the compiler cannot determine the exact type of value entered.

You started with a period, something should be before the period. Sometimes the compiler can understand without your help. This is not the case, it has several options, so it is ambiguous and asks you to specify the name of the class that you had in mind.

This will help others if you provide the exact class name that was missing.

+1
source

Source: https://habr.com/ru/post/1273378/


All Articles