【发布时间】:2021-07-10 14:07:57
【问题描述】:
使用结合而不是闭包的 API。使用 URLSession 任务和 .resume 获取带有闭包的资源不会出错,而使用 Combine 获取会给出:
Connection 57: unable to determine fallback status without a connection
struct Item: View {
@ObservedObject var item: Item
@State var thumbnail: UIImage?
var body: some View {
NavigationLink(destination: ItemView(item: item, thumbnail: thumbnail)) {
ItemRowView(item: item, thumbnail: thumbnail)
}
.onAppear {
let url = URL(string: "valid address")!
let cancellable = URLSession.shared.dataTaskPublisher(for: url)
.receive(on: DispatchQueue.main)
.sink(receiveCompletion: { print ("Received completion: \($0).") },
receiveValue: { print ("Received data: \($0.data).")})
}
}
}
Unable to determine interface type without an established connection Xcode 也有类似的问题。但是,在我的情况下不应该有任何 TLS 错误,因为端点有一个有效的证书并且在没有组合的情况下可以正常工作。
由于不清楚缺少什么回退状态以及为什么没有连接,您能否解释一下错误本身?
【问题讨论】: