表达式类型是不明确的,没有更多的上下文



我是Xcode的新手,试图使用rest api从SwiftUI的WordPress网站中获取数据。我已经从互联网上得到了代码,我已经安装了这些pod的

pod 'SwiftyJSON'
pod 'Alamofire'
pod 'SDWebImage'

导入homeController中的所有pod,并使用此代码获取数据。

Alamofire.request("(urlPage)(page)").responseJSON { response in
if let data = response.result.value {
let json2 = JSON(data)
self.moreDataNum = json2["count"].intValue
if self.dataArray?.isEmpty == false {
self.dataArray.append(contentsOf: json2["posts"].arrayValue)
self.collectionView.reloadData()
// ...

我得到这个错误…

打开图像查看错误

请帮帮我……

如果您使用的是最新版本的alamofire 5.5.0,请使用下面的代码:——

let musicAPI = "https://staging.mywowmemories.com/api/get-background-music"
AF.request(musicAPI, method: .get, parameters: nil, encoding: URLEncoding.default, headers: nil).responseJSON { (response) in

if let result = response.value as? NSDictionary {

}
}

最新更新