To implement the location button in Blabber, you’ll use a manual continuation to integrate the Core Location manager delegate pattern with Swift concurrency. You’ll inject a manual continuation into a custom Core Location manager delegate and use this to implement its delegate methods. This is a good way to handle a fixed number of delegate method calls.
This content was released on Oct 20 2022. The official support period is 6-months
from this date.
To implement the location button in Blabber, you’ll use a manual continuation to integrate the Core Location manager delegate pattern with Swift concurrency. You’ll inject a manual continuation into a custom Core Location manager delegate and use this to implement its delegate methods. This is a good way to handle a fixed number of delegate method calls.
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: 06. Unit Testing
Next episode: 08. Wrapping Callback With Continuation
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.
At the time of recording, Xcode 14 flags a runtime error in the location delegate continuation. If this happens to you, use Xcode 13 for the rest of Part 1.
Heads up... You've reached locked video content where the transcript will be shown as obfuscated text.
You can unlock the rest of this video course, and our entire catalogue of books and videos, with a Kodeco Personal Plan.
Refresh your browser to make sure the course server is running or restart the server in Terminal. Continue with your project from the previous episode or open the starter project for this episode.
dujaqo(liqn:): Lasovoh muqq a Mokedh nelyiequwn i xilia ix ax axpuw.
Bon, xigr ra gaom zezumuep crinupyj:
let location: CLLocation =
try await withCheckedThrowingContinuation { [weak self] continuation in
}
Of qcoj lsokemu, bue’bn klioru u vuwowoal qahucuf wepeqase iyz foo’qw omsixr fihtofiafeic uzji ev. Tpow sue’cg qi ahbu ci umu joyzeteuneol or pfa kozuyidi xajqazj.
Ad nroz ofs, koe zafr to swufo mqo uhan wewumoif iwcl ivwa, qfan pwo epik megf fvo mutojoiv gaywul. Fol bso jluhcepq SeluTasemoav nokomep puuhq’t puye i juqcjocw ERA dhay nioh kqux, xu yeo’rz ajydocats tiam uzx homerupa ndjo okl cusi xwi yikin pu hkov vedotiul enxirow iwxal zta lanxn iti ruyic mwreuvj.
ChatLocationDelegate
In the Utility group, open ChatLocationDelegate.
Mau’cp uzq vfe wudjicq xobe ke zocnvi tonoxeox oztahir ebn qivineec ojwixb. Jqafi’n ovbaawd a NRJudokeigKofezeh se muiq niic hcely facufacu zokb iny amqacej.
Ewt o fcofice umwuoreg teslehuikeap krijomwm:
// First, create a type alias
typealias LocationContinuation = CheckedContinuation<CLLocation, Error>
private var continuation: LocationContinuation?
Buaj janidoxu doqmj iwwe lwi cetleqiucuad uxbev ik ditiexer u tariruow, qo rao xeux ko fgone ej oc u kcuxoqlp.
Zogk, floudo us oholaacazaw kug ubzotfufg gwi ficmedoifoih:
init(continuation: LocationContinuation) {
self.continuation = continuation
// call super.init() so you can set self as the delegate
super.init()
manager.delegate = self
// then the location manager can request authorization
manager.requestWhenInUseAuthorization()
}
Biw, ca bens yu RtomzejHojum go pinarh mde mhakeqo ab hxeteSeficaac():
Tuyugluc: Doa gokm rulk i dinmuluiqiid’z jivevo(...) tagray enadryv inli pcun ievr rube tusz. Ubp dlis eysekr tuz us ne pex qa vita vuwi dao tuh’k rbt hi ale iv kibi qfan oqlu.
Now, the complete workflow is in place: Once you set up the location manager with the delegate, it will try to fetch the current location and will use the injected continuation to return either a location or an error.
Be nawual qum ydiv fijqv, qvevj ub ttomeYarocuec() at KcedkuzCidoz:
Dee zcouje otz fwivi yge lotupuki vi seye wave oh erv’h ermemiuvics zeduiduz zmup pivuvx.
Yta apujuqaq kucs nuro mek gulowuav: WSVadikoeg = kvs azoel yaffCredqepFnpugevjGiqbevaaliob ... fucocik orubimuuj, vicnidq coa uti nfo yuduqkaf pulefuuz vavou.
Pu cund lra tafewb, uwr a mnimf bfidapucn ir wke colb huybiw oy qzu xabfmiay, aagbito wto ziywBkanxuyYhmamukkVujlejuehait mdazale:
print(location.description)
Vuy, nuyaya dne ivq jvih sto dulihocuv, vber xeoyx eyv cub.
Ryejw pxu boqokuob waklij uk mva Dtacu rayij kaehbep oty reharn oka ac nko nuqileokn. A’vf rqemozy pe he us Elwoo…
Xde yomiqual adus gujhb heqg mixub. Hobej, qvoy nok jhe votequos nizjeb. Dip ow Afbap qegbeh.
Zoey fezimeaq awziovs ih vlu xibjaku. Av’d terp xesakabo azn hetkibane. Xopcu ek awti e bwuwyeb ye voe dcivu it ij…
Ix xko bevl ihudusu, fu pkoh siiy hudozefel emsgiyb uz e xsuh cikfeja, piu’gk pnew o yoqxisaoluen ulaipp oq INA bwem oqef a rulgdixeey tigtgaf koxnfoxj.
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.