Post

Replies

Boosts

Views

Activity

Xcode 15 b6 - "The network connection was lost" in Simulator
Hello, I'm working on SwiftUI app where I'm trying to access ReST API. When I run may app in Simulator, I'm getting "The network connection was lost", but it's working without issues on physical device. struct ContentView: View { @State var jednotky: Jednotky = Bundle.main.decode("jednotky.json") @State private var isOffline = false var body: some View { NavigationView{ VStack{ List(jednotky.rootLevel, id: \.id) { item in NavigationLink{ SoutezeView(rocnik: 2023, jednotka: item.childId, nazev: item.nazev) } label: { JednotkaRowView(nazev: item.nazev, childId: item.childId, parentId: item.parentId) } } if (isOffline) { Text("Using offline data") } } .navigationTitle("Fotbal") }.onAppear{ Task{ await loadData() } } } func loadData() async { let url = URL(string: JEDNOTKY_URL)! var request = URLRequest(url: url) guard let authData = (USERNAME + ":" + PASSWORD).data(using: .utf8)?.base64EncodedString() else { print("Can't create authorization header") return } request.addValue("Basic \(authData)", forHTTPHeaderField: "Authorization") do { let (data, _) = try await URLSession.shared.data(for: request) if let temp = try? JSONDecoder().decode(Jednotky.self, from: data) { jednotky = temp } } catch { print("Cannot download data, using stored sample instead") isOffline = true } } } The error in console: nw_socket_handle_socket_event [C1.1.1:3] Socket SO_ERROR 9 Connection 1: received failure notification Connection 1: failed to connect 1:9, reason 18 446 744 073 709 551 615 Connection 1: encountered error(1:9) Task <103A0196-6715-429B-A5F2-79698C6E9D45>.<1> HTTP load failed, 0/0 bytes (error code: 18 446 744 073 709 550 611 [1:9]) Cannot download data, using stored sample instead Task <103A0196-6715-429B-A5F2-79698C6E9D45>.<1> finished with error [18 446 744 073 709 550 611] Error Domain=NSURLErrorDomain Code=-1005 "The network connection was lost." UserInfo={_kCFStreamErrorCodeKey=9, NSUnderlyingError=0x600000c03d50 {Error Domain=kCFErrorDomainCFNetwork Code=-1005 "(null)" UserInfo={_NSURLErrorNWPathKey=satisfied (Path is satisfied), interface: en0[802.11], _kCFStreamErrorCodeKey=9, _kCFStreamErrorDomainKey=1}}, _NSURLErrorFailingURLSessionTaskErrorKey=LocalDataTask <103A0196-6715-429B-A5F2-79698C6E9D45>.<1>, _NSURLErrorRelatedURLSessionTaskErrorKey=( "LocalDataTask <103A0196-6715-429B-A5F2-79698C6E9D45>.<1>" ), NSLocalizedDescription=The network connection was lost., NSErrorFailingURLStringKey=https://is.fotbal.cz/api/jmobile2/orgJednotky.aspx, NSErrorFailingURLKey=https://is.fotbal.cz/api/jmobile2/orgJednotky.aspx, _kCFStreamErrorDomainKey=1}
3
0
1.1k
Aug ’23
Water quality homekit accessory category
Hi everyone, I made a TDS sensor for controlling a water quality in the aquarium and want to report values (and automate warnings) using homekit. I didn't find proper homekit accessory category for such a sensor - what would you recommend? The values coming from the sensor are in ppm (0-1000). I'm currently masquerading it as temp sensor, but it confuses other results in the Home.app. Any ideas?
0
0
756
Feb ’23
BigSur b4 crash fest
Hi folks, the latest b4 of BigSur is a huge crash fest on my MBP 2019. I get a panic several times a day but wasn’t able to find a cause. It seems like various apps and daemons using network are related to crashes. Do you see similar behavior? thanks robert
3
0
712
Aug ’20