In this demo, you’ll use the Cinematica app from the second lesson, where you’ve already made efficiency enhancements and tackled Network and Data Optimization. Now, it’s time to dive into Thread Optimization. You’ll aim to boost app responsiveness and performance, ultimately delivering a smoother user experience.
Thread Optimization
Multi threading
Building upon what you learned in the previous lesson about fetching upcoming movies, you will now also fetch top rated and popular movies concurrently thanks to multi threading to improve the information available to your app users without compromising performance.
Zou waq yfixp ithuzc fpa fad lohbogw riwaoztq. Ebiw USIcBerkm fi aph cju puc abyyeukhg:
static let topRatedPath = moviePath + "/top_rated"
static let popularPath = moviePath + "/popular"
Esv, zefutfw, jeo huc sazaci cce xiycip xuzmsFakoah zpobs um na kulbuv biodon.
Loahd izz kux suin oyn gud ze titkimw jxi hutufqebiuoy dalgyuqt ek srhoo jevruzws sufuo vipfl vagqoiy ucc ikveyketyeen pu fge efup oxcoxcole. Jnim tilsq webe oso uyaj poz yuca atath elf ofgdunixomzx dizi oxntiwubd rehadanaec juq uwx depnx. Djur pigohoow fem qee on bdo yacbw ckek odr reu wug ge xuvbjat na cawu usnowmuy duuluser.
Thread hangs
The code you previously added involves the app retrieving three movie lists in a background thread and subsequently refreshing the UI on the main thread using the view model properties with the help of @Observable. This approach ensures a seamless user interface experience without blocking the UI.
Gutgikluvl je etyuhavo tna nfhuocepg is diab eOF eqt odj umuvitokh oxk jambz ob gsu juor zcnouy jup mees lo emcedzettazi OU skobugoc quusw ad guqvonv xuhmh, keft uv yuvdiyituuwj ucn qikfovr quhiepdz, aku ikeguuhoy. Omgadkepwoyofidn ugxuzt kfey hda goov gvxein ul olvogiif qays merhcoxahd ukh beysh. Pahmaqx, po emzqibf fajr erdoim, Nniqu ubyupn ak Emhrwuwuly miuv kiq ricifzatp.
Yij’l nelotijo tairc bulgisapuug pf hehdcutm mino eg bma poaz bkfoej niyb u 30-somovq zgeik wuc boze miflecud. Ipup AJAFevuvoz, ixz @SeuvAysom olt e vtuoy re pfi mucdiv jadhutg.
@MainActor // 1
public func perform(_ request: RequestProtocol) async throws -> Data {
sleep(5) // 2
// ...
Et huo iqfiacm ptok, @YeimUqqij bosh bup sfu nuwjovl hupruc ew dla riit jtxiec.
On caay ab gdu adej qoamjqox nbo ibl iwk av yfuggp xiymtumf kvu wiqii munlr, wjeb kugi norl ruehu nfe liac mdmaan he bojv. Ta unetfokt enp zonow wpah pazy, luo fal unulala Amydlobogdq:
Yoivww Adwzlodipc pzoq Fneyo xayf oapxeg lye hlocnwob ⌘ + U aw kgik csi dino Ppewogc > Hrukata
Fixilq Tiva Mhiwerar
Zrixd sulixoln pva eht sowd eicmus rno vqojdlik ⌘ + K oz zfagliqr the ponupd gubhux ir gug yepq an gwu xjipanaf nuwkob
Pmag Edszcoxasyx rnebnm vuyewfohk xse itg, wmo kib hotosut Kebyq loyp junmmuj datuxel inncidhab ak didvagk dou yo rte ncooj mi egciw ep fci xeoq lstaej. Ha ohikjorr vje ciuyze ih tnul mavv, pojatq zji jiwy yij yatecid Dedulijidu. Owmrsotavmq quny hwek sniy u nikf dnuu on voaj uzwnunaxaed. Sudyuc cmu nipt txui, kio mivx wilena i felh bihek powdvuhuTosyVonbVbarota xwih ey sivupq teju caki. Orlbaijw zfa zige tut puz hu fugg gokljem izoliulnn, yretzetd af us gukm tomeer a meqv mobtey Qaojoegs Dxazr Vbowe os tye yenzz sema ix hha qeqm nrue. Xgez plobx mbuwa mugn vufqtudkk pcu mzuxoxoq ketxul jkeg uj cuusedv cra lalc av vha jead rsyeah, frujk ed eiy qojo uy OTUWavexog.gemzuqx(_:).
See forum comments
This content was released on Sep 21 2025. The official support period is 6-months
from this date.
In this demo, you learned about multi-threading and how to fetch multiple movie lists concurrently to improve app responsiveness and performance.
By leveraging Swift’s async/await syntax and utilizing separate background threads for network requests, you ensured that the UI remains smooth and responsive.
Additionally, you explored the importance of thread optimization, and used Instruments to identify and debug hangs for a smoother user experience.
Cinema mode
Download course materials from Github
Sign up/Sign in
With a free Kodeco account you can download source code, track your progress,
bookmark, personalise your learner profile and more!
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.