当在使用Alamofire 5.X 的过程中,出现“Type of Expression is Ambiguous Without More Context”错误信息时,很可能是因为有两个或多个不同的库引用了同一个方法名,此时编译器无法判断需要使用哪个库中的方法,因而产生了错误。
解决此问题最简单的方法是通过更改不同库的导入方式来避免冲突。例如,在import Alamofire时,可以使用如下方式:
import Alamofire as AF
然后在使用库中的方法时,需要如下方式调用:
let request = AF.request(url, method: .get)
此时就能够避免冲突,应该就可以避免出现“Type of Expression is Ambiguous Without More Context”错误信息了。