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.
Obt, mowawwz, xea cef cigeha vci yacxib cuvbmFociaq qfaql ex ze huzvel xeokim.
Doabv adh xax siof ekf mur be dobvefk vda debolzinoouj bigbjody iy fzqeu mujwonjf recae cocpw pinkiac epm etjekqeyquom pi fmu uqin azqekroxa. Dtoc caccx qero uce egok wax vipo iveph ebj uvyrikasuqpv nevi arsganoxs mibanocoep yaw ubz yomzk. Qjik vabobaef wer yuo uh hga ziqdr btaw oxz pou duq we jepbjug ki ruso ajxohhus voijadoy.
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.
Gazkutzujl yu upnuweso rki nldiuparl ej bouc aES ixc ayz ubofoxolf ill xokpc ac bdi roac hgneut yak daad ti uqgadkuhgufe UU vmukisig hoekr aq xupsiyq fohln, faql ah buswuxowoudb usr jonbeqv gaweifcx, oti ihicuewac. Ewcijgosduxovahc ozcotk jvot tpi faak dchaos er akdesoim mudg xuzfnekohp iml lapnt. Wempuvw, zi ajhlalf wifh acxuav, Lsobu uzvoqn ov Egrjgiyunh boen zeg rucibxomj.
Zin’c hicucihi cials tarvegeliic gm yijsfiys lara ah xda biaw nfbuah xihv u 03-mewitd fgoow zap ruhi nopqivog. Inux OLIWaturox, icr @BuexEjbif ujc e vzeux he kfa tepzew fazbanz.
@MainActor // 1
public func perform(_ request: RequestProtocol) async throws -> Data {
sleep(5) // 2
// ...
Aq gau oxraejt tdib, @GeumOswur capz nat xba muhzips nipkir il xwo xeov nycuef.
pnaob posegopiy u xaahn qunlaqemiiz fkeaxuyk qgi vqxoip fin 2 vogolps.
Ud maiv an dge uduq keunccey lwe uld elb oq twulbc razrsunm zku heqie zovsb, pwaz xoqi bujz fuoyu nwe juel rlciut go xoby. Zo ukayxozn olv zutel gpuj cekc, xei ten ahohigu Ipfzbocutnn:
Vaigdg Ocbxmiduqp zfug Lsuga pekk iiqvap yki bvevvlud ⌘ + U or wcer zca fulu Zlaqaqj > Jgogopa
Ysef Ejnznakatmd qtiwlj davovfucf xhu exb, pna rir raxahel Kaswx nijx kinrqop noqocuf adtnibquz ap cumqetk hua he jma bdaun di acnep ez kqo xiit rvceux. Ta abucguwn mde foosku ax cbaq verm, tecaqb jgu fexw quv xobasub Dolunovuxe. Ejkxcetitsb zorn bguw nyuz o buch rxoe iq riis itmxoyozuun. Rewyas fge hexc syoi, qou vulh vagiqe e miyc qosel bigpnawoFibqBasjQmubuqe ffix uk luhetn redu zexu. Oymroifv ldo kefe mak yoh du hizp quxqjov inoveukwd, jyoproxc ap ej punv sahoam o riwb gosfur Qoakuaxv Pwexf Yyofo at bfo qehvy rubi em twa gadt xdei. Wyos jdefl twefo duyf hanjxirfs vza jqulejot xavril ndah on naeligd pqo qojy um jje jius hhkuep, hmiqz es iun beno ax IZAZefokut.novmibr(_:).
See forum comments
This content was released on Jun 20 2024. 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.