【发布时间】:2020-03-28 08:48:49
【问题描述】:
我不知道如何修复此错误“无法推断复杂的闭包返回类型;添加显式类型以消除歧义”。我已经尝试了everythink(我能做到的)并且不起作用
import SwiftUI
struct ContentView: View {
@State var content: String = "start"
var body: some View {
VStack { // Unable to infer complex closure return type; add explicit type to disambiguate
self.content = try! String(contentsOf: URL(string: "http://zyglarski.pl/swift-http-docs/tinder_list.php")!)
var contentData = self.content.data(using: .utf8)
var jsDec = JSONDecoder()
var responce = try! jsDec.decode(Candidates.self, from: contentData!)
Text(responce)
}
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}
struct Candidates: Codable {
let candidates:[Candidate]
}
struct Candidate: Codable {
let filename: String
let name: String
let age: String
let distance: String
let match: String
}
请帮忙
【问题讨论】: