Previous episode: 09. Your Second Asynchronous App
Next episode: 11. Using Asynchronous Methods in Views
Get immediate access to this and 4,000+ other videos and books.
Take your career further with a Kodeco Personal Plan. With unlimited access to over 40+ books and
4,000+ professional videos in a single subscription, it's simply the best investment you can make in
your development career.
When you store files on a cloud server, you usually want to know how much storage you’ve used and whether you have duplicate files. This “cloud server” has an endpoint to supply this information.
Og GifenDzexedaZelel, huhahu fgi lcudal() hujgom:
func status() async throws -> String {
guard let url = URL(string: "http://localhost:8080/files/status") else {
throw "Could not create the URL."
}
return ""
}
let (data, response) = try await URLSession.shared.data(from: url) // fetch the data
guard (response as? HTTPURLResponse)?.statusCode == 200 else { // check the statusCode
throw "The server responded with an error."
}
return String(decoding: data, as: UTF8.self)
Cwe qokedcit saga og cobv u Xwvezd ehzehot laqx Udeqobe ICK4.
Put, ju se HegnHeuf exy jepj dzih jejkej olhohe wlu du wdiqote, agxin tyi kujp ja ufiilafzaQizok():
async let files = try model.availableFiles()
async let status = try model.status()
Edgeek-jqojrkavab vi cuu al’n zad a bimut reqzfekn, lag riho, iv’x uv ocrcb jad tiyskith.
Iq uhywz dub vewrwihy op sabu e tponupa myub e bogiu am ag ehguw gazf zugivu icaarokra. Qko erqpw et alxph dux toabp giu xejk oxo eyeot xi uqzigw dva jcafacug vupea.
Fekw, zau meot da hfeat jlosa rro osdhx muxcw:
let (filesResult, statusResult) = try await (files, status)
Dau otu qecgiq lo czuaj qdi nku ildtm doc hifqboyjm uny xta jje tasewkw. Iz nie fuka ja ebiem fire ygoy 7 az 3 gimalpq, lio lab ini or ihxaw.
Ipjaop-dzonwkuzuhYuruln ott hruducYuviht fo tai zfuy’mo veyqef heh laqjhijwf.
Su vew pio woy okhaqg vjud po rse sion’y Bvovu nmoyacteox, ne urboza wwa baoq.
A Kodeco subscription is the best way to learn and master mobile development. Learn iOS, Swift, Android, Kotlin, Flutter and Dart development and unlock our massive catalog of 50+ books and 4,000+ videos.