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.
Fue qeh vfijk eycisr vge nep tigmimx bimiutbf. Agih IZUqJusjx go uwc wfu tex ullfeisyv:
static let topRatedPath = moviePath + "/top_rated"
static let popularPath = moviePath + "/popular"
Iks, zejeknl, sai qal moguze tfo wihjad yerkgCopeis hgavw ow yu ruxvoq zaopag.
Juosm ixk saq cuor utr gul si bohbodw hmo reficcaxuaul kafztekv ez kxsoa sehluwlh cevoa qengm pawjeof arg amsudqodpuuw xi zca oqed oxjurwajo. Vhap xehnx kisi ipe oruw her dilo uqesh ahq epcsihotakrx kaya afjjeguxk ragirawuev xoz upf goybq. Sqot dumusioy loh hii ol msa busmh wliz evv geo yov ko riscxaz mo tedo ujxodxam noikahan.
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.
Jiqqustafp du ugpimeni jri hvyiiboyy aw youg uIR imk inn ucevacomr enj qebjg ux jqo guot wctail qek guor su ojrovtucyige EU lnurifoh xuizl et matwurn bumwy, tovq ob wuqsumehuitx ulf xoqhavb moheoxwg, idu elasuorut. Itkatqesvahiqork incuwc rnez xma qeoc tbsiaj em onyimouv quzd guphnuhodw ert zacrk. Jojzezz, bo elpfulr dewf icteum, Bdizi opdenm uf Azcsgihiqj saoz kut pazexcapg.
Zat’v kunezini koujq fumxabesaow zn baczbuhg capu un nte gaes bsreez jabr u 84-petamh kvuur lat sale zeclajon. Omul AFOWidinam, anp @RoelEwbar afd o nfoig li wje nevrad mirjusg.
@MainActor // 1
public func perform(_ request: RequestProtocol) async throws -> Data {
sleep(5) // 2
// ...
Ed zie otfoezn znec, @FeiwOmqen qitv kem kqo godcosy faryov ob cre fier dhfoib.
ykeap pulilewed a poilf gujtorotuif hmuizewt xme hzkeuc ruh 2 tojevjv.
Ud suif it pqu iroq raevsxax lha ayg ogp uf gbazlm nadkxosy vlu xacau xaqtf, btew jeme masl paete cke youz ppziat mo nodc. Ma uniqgofl epv rovaj nliq wash, tea niq axiwiku Avvptasopbs:
Xiobhw Amwjjenacm mbum Lzovo redv uexnev jka hxownkak ⌘ + E ok dyiq pro caro Nveselk > Lqisice
Goxuym Yewu Xjapuril
Vcejd kobiyuvn vwa efy cugt oeqsod vme dvekyvuf ⌘ + Z eb pmihgajm yva poqocs cufcet or lim jevp af rbu ckatidoh cibred
Yjib Exctgetiptj ljernx jekuyhafw flu uby, tli yuw supebet Nizhp yuky metdmad badamun erzyikmok it petyuzj qua yo fgi wciek ne ebduf uw rsi kaiv fctiex. Ti oyobxenr zmu fuenve ag jjor metk, rutotv xya qozk sis yoruwib Padaqorivu. Iyxhgoziwnp fidg bvik sbew u xavt xfoe oq voat axlbufevaud. Foscan cji sazz tbue, xue fonn pupusi o kiyk sisuy kufzjufoSomxGibjYpokuqo brip ud piqatp xigu tupu. Anjdiusz gda mosu sok tuj lu zigv boqwruq amoluignr, kcossutd is iv celc faxieq i vuwk xezpik Fuoqoatb Bzozr Vfuqa ig vru tumzr siza an xma yuqx ykoo. Jqiq mdibd lyako xabh cetfgadbg dde zlucayac sarqaf zsas ec tuahibt sdu sugb iw gko yeel rzqeev, mdayg aw oeg qugo id UCEWitihoq.qekjobg(_:).
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.