小编Eli*_*iza的帖子

'Result<Any, AFError>' 类型的值没有成员 'value'

我正在尝试从 API 获取 JSON 数据,我想在终端上打印它以检查我是否在终端上接收数据,但出现此错误。我目前正在使用 Swift 5 。

import UIKit
import Alamofire
typealias JSON = [String: Any]

class NetworkingService {
    static let shared = NetworkingService()
    private init() {}

    func getPeople(completion: () -> Void) {
        AF.request("https://launchlibrary.net/1.4/launchstatus").responseJSON{ (response) in

            if let json = response.result.value as? JSON { // here I am getting error
                print(json)
            }
        } 
    }
}
Run Code Online (Sandbox Code Playgroud)

xcode ios swift swift5

5
推荐指数
1
解决办法
5251
查看次数

标签 统计

ios ×1

swift ×1

swift5 ×1

xcode ×1