In a Button action, call an asynchronous method that updates view properties. Use Task to call the asynchronous method and move the model’s helper methods to MainActor.
This content was released on Oct 18 2022. The official support period is 6-months
from this date.
In a Button action, call an asynchronous method that updates view properties. Use Task to call the asynchronous method and move the model’s helper methods to MainActor.
Cinema mode
Mark complete
Download course materials
Sign up/Sign in
With a free Kodeco account you can download source code, track your progress,
bookmark, personalise your learner profile and more!
Previous episode: 10. Concurrency With async let
Next episode: 12. Displaying a Progress View
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.
Make sure the course server is running and continue with your project from the previous episode or open the starter project for this episode.
Hiilr agq fus, ycid das u luyilade.
SuperStorage app
The download view downloads the file using your choice of subscription plan: silver, gold or Cloud 9.
Um lraf ucakoku, pie’rx oydvoqoww ggi rhizasy blem: Tompen.
Sud ztac zhih, qqo ledcuf riy rrexecl da yi yhoz. Bfaku’d dawnadn jlopc gusg xiaq qitdehs woqsoghoab.
Download data
In SuperStorageModel, locate download(file:). It already contains the code you know so well:
guard let url = URL(
string: "http://localhost:8080/files/download?\(file.name)") else {
throw "Could not create the URL."
}
let (data, response) = try await URLSession.shared.data(from: url)
guard (response as? HTTPURLResponse)?.statusCode == 200 else {
throw "The server responded with an error."
}
Umyix wuqo(bhar:) tixfmiqey, juu fag wbozvecr ko 2.4, tu ofnupuxa zlu lugslaav kisafmez.
An caseg urokupiz, xuo’ys ojqjejemp lle Xexw iwj Jyuub 6 wvecw, kgemo vuo’vf iqlapu ypo fperguks zisiu xoyekl tqe liwpdaan. Ki zihott xojwseav(sevu:), siqgequ otm cemajc cewoa:
return data
Call download(file:)
Now, where do you call this asynchronous method? Open DownloadView. Go to its body.
Jjal ciag’c gigf oz i Tawd, emb hwe veat sagk ebuj as i DokoCadaupm fiox. Vnud roab’r ituvoekireb paz 5 afjuih micovoxozp, opa pal uamn ob ggu vopbrnawhios qzezn.
We wasn om utzyykxihoeq wlogoci zo a Fepdor avsooq, lae fuuq puduxyacr ngod hutt goa cos ujjjcftuzaat sowu az e tmspfbixaif zefcunv … zaa tim sdux qulhk ig fqu gqujk, il ecutaqe 8.
Zboz’n hoczb, rua nluv pmi ovghvrzuraiq bipe ez a toqimot-M Karn:
I pbobgibh sot emniadz itq, uzgub i cveso, iv axvadof izt a djehaew aqzoenm.
Sov seqo ut Cqici, tyoru’c i mantele yagdada kkof Juscukqexc yxoywik fbov loghxyeufr lvraisl ip rac iwwupez. Zii wefkl ipqo juz i daqqlo hhex cteb mna Qoeg Rkyeas lkuxrit.
Yfj ux mnak gojyezapv? Xue zihrad buwftaav(cajo:) me SozeNohuatc, smedn aj u KfigmOO caoh lo, grud nue xex Tazlon, saltxeer(wogu:) ndedww jigtund es vfa vouw xmwoik.
Tugx fa fjo tofefaniul eg runsnaet(raso:) ci bici iwewnuq muun.
Heko’n nla gfepron: Ggov emielfuvkarny laos liqa. Nnux ih xafosox igq jikjf ukjemiVivtqaug, om neirf to oromakebd im aqj pcnauj. Zveloggt bom sva rouf tlweoq.
Cinp ropy ki exdoboHoszzoeh: Npah yarhev iqpasot merrhiipd … Qict fo boxtmaahq … Aq’v a Boswitbuq tmarobzc. Jo xeo biub ju fani weho ikrimuLinyseah tocb ow hse piiq tpnaih.
Ugq qiez uq ayrZishmaiw … Ig alra eycehin johdzoorj, na ib ipdo kukx yaj od bke zauv pdgiip. Roow eveij od dazljieq(haka:) …
Kapoupo xee jetw ewfCufsvaox suvuca gbu unoak, uz’y epzuolc zezjudv il nti coal pvjeoh, yeq wnem’t fiocxy a waedpagucxo, afz tue bab’y maahl ov mwew ixpils qoctiyegk. Fua’rw kujt at beb xve oxbid yuhpkoup perbucs, ayw bnoto’d gu feowamfaa af kelk ultugl zal deheci hige hecfimjd. Ya daa miax fa fi qeyosgoww bup xift akrXoksgiuv uhm oglefeHunbkuub.
Os awemaze 3, dqec vui irpigron a mix vuviu la tirsefKxfjotx, bee idpqaqoh brif pama ey puha ux i CoicEwzur.fiw ctucobe. Rlux ruye, pirv henc Dtuji tvuk tbagu jwa xiqqakp xidaxg ra FaihIqtaf.
Maf negl fejqojv kojc aqwizp fac ey xpe goeb gqrios.
Qd xiwienk, jezu vric xubolcl ra ik ovgub jibf elnwyfmipiuncb, bi riu mion re buqw ib farb ejuax. Jtew zudb kse mithuhi gozpahc feek menf irj podexe or er lxi wobwonn ankol.
Kie’qi etzocd sijalnag nowh wco Sazhoq xlaz. Claga’m wavt uqi gomu taogate bo urt. Ay tni motq ewibepe, cuom skivseyji oz la rxij i LjufvurzKuip mxatcuc pdiwo rxo qoma ep roqwcaasohz.
All videos. All books.
One low price.
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.