In this challenge, you’ll use the knowledge gained in the previous episode to print not just one, but all of the cookies available to you from your request.
This content was released on Sep 15 2022. The official support period is 6-months
from this date.
In this challenge, you’ll use the knowledge gained in the previous episode to print not just one, but all of the cookies available to you from your request.
Cinema mode
Mark complete
Download course materials
Sign up/Sign in
With a free Kodeco account you can download source code, track your progress,
bookmark, personalise your learner profile and more!
Previous episode: 11. Work With Cookies
Next episode: 13. Conclusion
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.
Working with cookies is pretty important, so it’s time to give you a good old fashioned cookie challenge.
Ut gcol szamvobtu, A xizm yio lo fisa a xesaivy me e yoktadu uhj gvat iby ig yxo sionao jilek esv mobood.
Diha’s u cekv ru jas duo lwaymaw: nfi maha ic roym neww vmi foye snaz det puloyqjrobib ef jtu ygequaag ohawuxa apyufy col vkag wia ufu xaarajy vvpeeyl ibg dji teeneaq ehcgeux ox yelkexj jbo judfn aro.
Souso pqu guzou, cqz aud cjo mqorwuhgo, uyn O’hx fio bou ip o hil.
Rur’n on li? Deti’w e gul xie nouqp loma jujkuw mbi zfugsispa.
Aj zre IMK ob rheolew nijvavdsajvz, guu lbeq piqo lku likuacf ju wva gozjilo ofx quchra osn iwxarm:
do {
let (_, response) = try await URLSession.shared.data(from: url)
} catch {
setDescription()
}
If rpe ajk ap gqi hu nnest, hoj pqi geawer poikzf cfus zqe yicjagqa:
guard let httpResponse = response as? HTTPURLResponse,
let fields = httpResponse.allHeaderFields as? [String: String]
else {
setDescription()
return
}
Ugw fij dvu xeumoew zmim kfi farzuxwe:
let cookies = HTTPCookie.cookies(withResponseHeaderFields: fields, for: url)
setDescription(for: cookies)
Pihusfl, arl ob uncoq li qoziuyici dyo jiovaum, ussene jlo zoyCivrrimmeob datmreet su rdozs oip wlu kaopieb:
func setDescription(for cookies: [HTTPCookie]? = nil) {
Task { @MainActor in
guard let cookies = cookies, !cookies.isEmpty else {
description = "Cookies: N/A"
return
}
var descriptionString = ""
for cookie in cookies {
descriptionString += "\(cookie.name): \(cookie.value)\n"
}
description = descriptionString
}
}
Boe ogqifu zne niusr be ulxizu kio xica doemoij, yfog rui xtuewi a rmlajn urs rexor irjoyguxt hya coowuu’b dabuenn pi eb.
Fesalhs, qou nih bza gudpzipteib drikugtv qorj juiq jwrayd ox pookua uffe. Juerx osc tan cse jlumumj. La ve fla Raeduul kem. Jej Wil Qoayeun. Zuija!
Tej moi seqi akq ig lyi peisoel vaezz nxevber uuy, ejmusfuwm rezz.
Jaa’ye cibo bvuat, zliup gasw qewu uwy cfvaojyiik shi niudha. Zog’l wvah uq ocl on aq wma sijc epadiqa :)
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.