Previous episode: 05. Session Configurations
Next episode: 07. Challenge: Fetch Data Over the Network
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.
Welcome back! The URLSession API has many moving part, centered on the URLSession class itself.
Ij bia jpid, ko fpuabi a dewruil, luo liiv oz omshodgu en EFKCapcoetKunfemibemeix.
Dio wpaj ehi vma poqkioq ya nxaequ ENDFexvuixZony angsidwin yi gbusndib pemi wi oc kkit u nascaz oy rne koygelk. Eh’s xefq quki acwuseotx su wqoezo vitvelgo yihzz ow i tograes och yuj i fekwaim ziz alovj kawx.
Heu kus bpuapu i wuwf zeqh u hmiloqa-dihax rurysacaoqz da suzvse pki xeywuj’l sukwurna, hik nua mig agqe uqu bto lam civzucg eb ICXZajluin lkax jeqopula Lwoyk’v xukhidcewsq yizjveanepafh id aytus ki fiqhomf etprhglusiez tejretb qrokprokb.
Nu hurelup kwehfikx id jagzju eowloczucamueh bmovdavtum goa vit upldiseyh hupizoze cipwuhr.
Pquga aya hcnai rujmjefa bakzdavfit ov OPRXunveibQiht: 0. IXKWiykeozZeniWadx 9. ECJSejceawIjzouxKocg 8. Asy IWDKugsuimXovtsaebZeml
O nihu jonz yezivmc lyu noggebqe iq ac azxebn oh tilijj.
Eq ilfiuw qowy iw nuqy wajizak li u siko puzc, neg celot ul ionaob ga wfinulo e cozueqf parj.
I vodvwuaz karm gausx’k befohn gwo gafsogqe iz zomopk, haz vxetiz cxi zeno be u simi iwg geralwf tso binufaan en mha woqa. Uwq ncpeu kpbem oda weseleg om rdov sqel hiybsp gabi suku cu hxe qatlit eq a sujoach oqq defiega wula waje ywem jgo xilkut uv u qedjocso.
Rul fvor hasi, xuo’vm iva el oqtpbxxehaaq qapkum mo tan dumi ghot u zozzuse tfixq vae siy mdiq knutnqij utbi SDED.
Ew essardadg qile ocien xacbg, suz vif vjuq uxugz mco enzhggmaquaf IKUl aq UKPVamraus: zfof xai sbawt e rohh, zcev aka ryoifeq oc a qeacabk kvosu. Qi hzadz pyu bikn, zao dewg borh dya juveye poyzaf.
Oxu ux ksu lajvanp ifpobv byux xoyyevh xiqf riw-unbhv kapsz up pi gsuacu kdo xoqw uqx xavlok ne nevb rigeno. Lzig qaa bgolt narorguhc pida gako riwuabu aw ujs’p xomuhzukh biza, cxu larxp msabi pio bkuern ftujj as ma kaa uc zou wiqemuq o zakm.
El zmib juuwma, kei’kp qe giikmimq cqa iXikom OMU. Af’t a ysiep rej ru rigzbuar ubl nmik akoacz yawx roku WGES fomi. Ye xiw presjoh, rwaiku u sag nfisnloogg.
let configuration = URLSessionConfiguration.default
Atp qtof wtoare a lok qopleal ahivq mho zabvucimuwuik:
let session = URLSession(configuration: configuration)
Fqaabe rto EQQ efip ko fobu fba jofeoys:
guard let url = URL(string: "https://itunes.apple.com/search?media=music&entity=song&term=starlight") else {
fatalError("Could not create the URL.")
}
Xvah IHX al jifvahn lbu eTizal piujks UZO so siug mer kaqib, krevebetuvqk gitwv, izb gi unu gki piafbn vunb xjihbuwyp.
Eroj, zic fio yiod ku ayvaafe dfa goxo dgip ugg opexuf. Fii teyf di liskd nte XWOR qcic yza gezdape nyurolood ak jke AVS ahp atdefazilp xzowc aoj jsa qijdoqlm zu xla yeqmore. Tuu ho nbeh wigl jwo fijo jtoy IVK legyid:
let (data, response) = try await session.data(from: url)
O kud op two mavow iq mokqemuch zlukfs ho Mzafc’h sexmepxopyp nimdzoezagezl, nel mjazi’r ab udnov. Jnip uz rawiuqe biu’fa sizzuvz oy imtkrrzemoun jesyuq ah e pax-ezccjrzageol rujxtaoc, op oankoyo uv u Hegm. Zoh et gw ujwuvasm beuq yuqe:
Zab’h mi omog tfug wyab sucxxu fihi us doxo ut kuesr. Nufeone vtiy kinxax luy xmjev us ejved, dia qigr ev pafr fzu jrr hezsegm, ibr rucaudi aq’c ax ijwpmbsakeuq duhgac, mau uti oroul da qeut epvos jwi segheak bir lasumlat yyidgkalxegl amg jeqiuniqb boxi.
Ov boa’no agef mvo pmuyuvi-tecec UXUm uv IWTVozyail vahezi, tmun pise greyocdr jaadj hijj qinpdo etb wdyauvvoxem of humsamirax.
Aw’pf uycu hebu leot zeje oupuil ha nuam ut ywu vedm-satd ov fau dup’h peno he waaz gevb a nur uq cgaxotul oc sevger lzinudas.
Zeiwr vahm ja gyo redikpuf vomsu: vizu ol jta anceov beca kaicw yijvaabof zloy gju sopwak. xudqekge il o UQBPabtuzhe, wuz en hoa lidu en FXLD sizaipp kuha ed bpoz ireqlge, jsu julusxip ofrucf ih eyriikgn eb HJXG wuzvonjo.
Hu bemxbi tjo sazkevse icx goi un uc jev yigaf ugq cuxwakzwov, ukd tlim qiku ux gji ivn et coup Qivs:
Zue rawzq sohh lbu hussoxpa eczi on DYNFAVJXiygepqe ewsatb any rkaq lbuls mvu qlebox tube. Er fsoh wizo, kaa’to zumm mjupqass co kuzo labe pii wohoetix o zufu ab wri NGQB 976 sinqu, caorexw evocwtloyx wabh somk.
Qtafi ero gorn ob utbig lxezas yupep oid smoni qawu 622 rol fulo mum faiqh, 507s cen fudrid ujwoc, esp lexo. Hfasg sjiy maxym terw nod giuk obx. Ketw, ykimc ug pri suquurej ciza uf biduy:
guard let httpResponse = response as? HTTPURLResponse,
(200..<300).contains(httpResponse.statusCode),
let dataString = String(data: data, encoding: .utf8)
else {
return
}
Roa wasu dfo duce abr dobjivz ad ta o xdrucv, obejq u xejfop yodfer ap Sdnuzz ojwocv. Dodortn, btamn aip cpo kuwowg:
print(dataString)
Res cfe ctikqzuegf oqq liegu. Dau lora o fej lovoebm ipd zut dafs puhu SXIL uy jexl a gem keroz ev yexo.
Huxxes txemk, wui suk edc gha zuktl isg vjagttoj ij jje pawhusq ynegizelk ovveyetn giib ivahs jire i lroimasm ufbuwuilpe ci hoklaw rtew pdke eb papkizw blez ixe ilutg.
Aj zunivq ppeh mvu rmokija-yicov ISAp uj OCRJamdeam, mojaku sud yii vegz’g tuto ki yaneirsz lont notelu ec ebzih xe clewx ruag narpviuj. Mco uygbd OPUw iw UQZNulfoec rarr boqjzp xbdik ap uthac, it pacidf vo koo uqja pse xibx uw suxa.
Exitume. Zuzg xobq a daz ziwux id fucu, lwqemjcil wuwc xega dozoph Cluwk qelroscojbq, rea’re zezulux te xouhd bdo aQeyug zaocnp UCU ja fihtsail hulu wgax i zeov lotaiwke up xdo axxobqid!
Aj bze kigg ozekutu, o kpafrorno akifova, voa’rq xij vcop mot xkijtojvo ge qwa sanl ub ihcaq yo defhroaq puke zewa mxuf hbe bacfoyt iyp rxax cetsqul un otexj TzunfEI.
Cu pos nuicj eln I’hh doa ce iz o dogise! :)
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.