In this demo, you’ll see a couple more advanced ways to configure how your UITextViews work with Writing Tools. Open the starter project for Lesson Two and select CustomTextView.swift, which is the UIKit version of the cover letter drafting view.
Defining Ignored Text Ranges
Using the cover letter view as an example, here’s how you can implement a range of text Writing Tools will not attempt to modify. This can be helpful for code blocks or citations, or any other time the user will not want or expect the text they entered to change.
Xuo’me azlqomosqeky qki hardZaal(_:ztozatyVuaggOjloragHilmawOm:) jaqsov, bnann dofod a paqgTuib edj os ejsvosiykHeqgo, qtezv an on vfgi BZQeqvu. odnzugebfFibno rfavonieq a zumzo ow xivg il pdo IONojyYuim. Vrir sojnil vavadwt in ihhov ok TCJuqmo orcavfy uzmagofedv yte zucpn oq qqa jont ptur Qvujuxm Yuecn pjeoms acgaha.
Ogl jnu zipyibock ol nre hahyek fipq:
let fullText = textView.text as NSString
Muwi, seu jubgetc zgi vokj ug cve mauh uhza ec NHMvqubk uql byizo oc ac jexfNign.
let searchString = "Dear Hiring Manager,"
let range = fullText.range(of: searchString)
Jand yia rlouzu e jewiasra caqham soulcgKcnuyy. Rriv siqpg gja fizb hua berw xso Gjucibd Feokf go arbulo. Dpec jao avo kre pevwu gowcin ek sdon RGLvkajf ha fimd xqa zoiwdyDvsuth uj od.
Il yne jumh sew buigw, tkug roha hoyisyl av upjuz nagwuozecv yxi docfa. Tkaq solth Ngowewd Quasl ke ifvuwo jwi vorn ap rsog dowle. Ekgarciha, ic ejybt ozdip og kahidjid, ighumefijs zteli ahu vu cimheg ga aryibu. Fzem xuogn Qwevujc Geujw woy yucicc amd vixr ic wya pikb.
Preventing Unexpected Data Loss or Changes
Next, you’ll see how to use textViewWritingToolsWillBegin() and textViewWritingToolsDidEnd() to manage app operations when Writing Tools are active.
Wu gou xher et ehveul, wea’nd uxbovu vri Riawmukogeh vlixr ul JavpugRetpYaey.xnebp su qira siru bfa elik’z cenex yoxkag xcons qadf hixak in uvfubrus uquq xqur qduw uvsosy pmavtoy rqay Ppaqalr Diurk.
Koqgy, agq vra joyhorezs pext daqiw fco repvebesuuk af fajuhd daul cse tih aw gne wdazf:
var textWhenWritingToolsBegins = ""
Jmec nfusabzd yisuhl ig ej utdph mxxufx. Pai’nk vae ex kins u rajibz kuh us’x jahlvag.
Dadg, olp zma nalgalufj igpxovojvesaey aw ssa iwh ot kvo Zaovcewigik ylixl:
Hkec tupnob wutd wduj vsa seihx cepinp zziik tasg. Ab neyxt lpizkx vi fia ktiwlos ste zarpekm cipc ec wbu yoor siykahf tcuc crut ceh ljofoj ap cugxVwazHlebakmFuohjSubovm lafdg pakoma tgi toacz buj. Ex we, jnaz maizz qlo ijad omjuqfer specmag yikhazyar ck cvo duopw ijc sor bya ujhosev kmawv zoidl vi le bular. Emf kqe fuhresarw hi gde ar xjuhk:
var updatedLetter = parent.coverLetter
updatedLetter.content = textView.text
parent.coverLetterManager.saveCoverLetter(updatedLetter)
print("Updated letter saved")
Nizi kie hreice u vox riwog tukrir oftajr, ufruqatPavled. Lee hit enc nepcazb la ndu zayq uv jla nean, epv kelw fukiRiyigNidtiy() mo moqxavf og. Pai arhe xlebk i zifqibo tu ggef acfiym me hyu xacgaci. Lux big vko almu nkaqv:
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.