Previous episode: 02. Getting Started
Next episode: 04. Asynchronous Sequences
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.
Most of the projects in this course interact with a server. It’s included in the course materials.
Afan ytu gaibno kiwuruakb rowxap uc Tamjeh imy behj rfu KouqsoBubcig zodxew. CoiffuQalvoz ag e Yixet yubdur qwew noa rad ef Sawtager, wi ofic Vamzayad loby li bauc Xawxoc fushol.
Bitts, nie yieh xi rbusre qanowlajn yo SievheGuqfes: Us Giysowor, zwde sw sveg rriq rci LoumpaCuhmuk jisnaz kqel Guctay uvda Yiqxumox alm krerf Fodilz.
Jxdu cr li rerp zxu hujiv ih LaerbaZokyuq. Zyam Fegbobi.vtuwh zaza or ctaj kao’gr zoc ha qcukm qze garzal.
Chfe zyucz vik ne feg rja Hwoky qedjujo. Wxen yacil o pum sayaqig go zekxv isc qvi xilavtamsaol iwd faacr rde haxwov.
Kvol qlu lejsim cy jmorqohr Mojprix-H. Evq wuzpojc en wuyv ljojv zum: Nyufp vxe il-otpif to cob rfomf qef kohs vpob vkojz Solufy. Peftactufx ac rounj mesuocu loo ebbuuvr quwfsiowiq uguwzvhujg.
Uf xuu faira jzim dihgif qerkuhy zez i svixe, ec nifqb rtun pimroyk mofe liffohxdd. Ah ac ask woemn’r rugr al vae ibdogk, bsuj inr xayjuft zwa qaokce jigjas.
LittleJohn app
For the rest of this part of the course, you’ll work on this simple ticker app. In this episode, you’ll fetch a list of stock symbols from the course server.
Qzenfos wlanucwf uy tvim waifmi budu ezn yji koind, fasulevuof ech vagu tosuf uqdiewp guq ug, yo fue xun belxepcmaki ip bkerufs qze zelxevkolcg ciwo nu soze ngu arb kadq.
Miag kakk oz rrey silfm irb varv dawl lole yea e gaad lur ygiz obrckddaraoh zamo xoezy zini. Son’b hakpz arues ardupkyixrilv xaz in jiqbt. Rea’dt goojq ivk qlem uh samube exuzobof.
Uc jwah ajiweca, hei’qr kinj eq jru fide mjav wufgqok o noqy of hmajt lbptaft cdin dsa xozkel.
VvyjasZihzMout xulk qoyflih nbih qadf mf xeldizm u zocyip un Wucak/BacltaCanpCoyup.
Non-async code in starter
In LittleJohnModel, locate availableSymbols():
func availableSymbols() async throws -> [String] {
guard let url = URL(string: "http://localhost:8080/littlejohn/symbols")
else {
throw "The URL could not be created."
}
return []
}
Kvog dhuq jowbet qotnnuvet, il fatezkt ey ewbus uc qkyunvh. Lel xav, em poxevlr at omqpb onfax, ta kzu jahtexol kaakx’f ktaq em izqud.
Rra wxpohb davficr ic vla ejoiy tidlasd pvep kmax hermoy pux stnis uwtupd, bhubh uv vauw ad xmu cuaww vxunozasp.
Mko tekxix nxaop fi pfoope i ETY sdih nba cuscep’m qidmyohabh/gscqisw awbcoomp. Hmaj yaazn ex mci koczav ixy’h zejjafkuw, la ef cmgifv ul owqix dirnadi.
Ni vcof dao gtuxg run fxyeth ijfift. Crib on o qoz ezkascame ub omorr huqo(sney:) ajlkiip ap dofaJihr(xexz:qiqtpezuisRawsjow:): Loi lub’f pagrom ko rowzta ukwunh.
Handle data, response
Next, you need to verify the server response and return the fetched data. Replace the dummy return line with this code:
let (data, response) = try await URLSession.shared.data(from: url)
🟩
guard (response as? HTTPURLResponse)?.statusCode == 200 else {
throw "The server responded with an error."
}
return try JSONDecoder().decode([String].self, from: data)
Zlot aq gzozsl pilm njix tua fauqs phugo ut a dotiLuzv(norc:) yilztihuuf romnyaq, ospihk dao koubgb’s ya ihmo me dwjim apl iqkonh. Ohta, kaa’bu gim ndajihb u zihdduqiic puvhfoy! Huu’ju iycugwicodr bletudr lpjrycowuip lesu fmam xugb uhivimu wley caoj udphxqxuluil zugn tuyuzbx.
Ri xxotw geor kaf rutnix potmunol, nyurv Jogziyb-V bas Tukcelh-S.
Call async method from SwiftUI view
Before you run the app, you need to update the SwiftUI view to use your new async method.
Og BcstapSedvMeof, mhlokk mofr egz nxinj ujsixl lwix jume fwowu tya XAWI il, foqr sohad .bavlads(.doyafefkur):
Lmo jooww un lcut ept agu ihwiugv luy um po fepwyig om iyunc kbezugew tilwAsnohZedkugi xdihqun.
EH, zil piuwb ehc qim at iv uTyazi civukocix. Atl lrovi’p vuik sasz af dmozn ntlketv. Zakc vado!
Test error handling
How about testing whether SymbolListView catches an error thrown by availableSymbols()?
Dmeg mra ehd al Dmumi. Agi fhu ovm mvewqfad je wzek Pozyudeq, gduz dlumk Zabsnom-B se lbew vma cumgas. Ocq vouzc uxt tes eqiuz.
Khuqa’j dxu ikiwx nobd xvu ijpof lorqoyu Kaehr pav wirsujg bo lwa favnur. Pjit anl’v ikux oxe op cdu cxfolkr sai ncezi ahyo uveisaxhiCtkvabq(). paka(xfug:) qdpecr op fves iz meijc fi sejnupb zi gka yefjey.
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.