In addition to requesting how Writing Tools looks on a view and the kind of output it sends back, you can do a couple more sophisticated kinds of configuration:
Setting a protected range of text that Writing Tools should not attempt to change.
Testing whether the tools are running and defining work to do just before and after so your app operations don’t conflict with what Writing Tools writes to text storage.
Defining Ignored Text Ranges
Although Writing Tools offers useful suggestions, there will be times when the user expects their text to remain exactly as entered, like in code blocks or quotes.
Ke eddiegi rtoy, heo’df oke vru rkeduyhRuomhOvfufacKupbibOg wawecuna tuxcul.
func textView(_ textView: UITextView, writingToolsIgnoredRangesIn enclosingRange:
NSRange) -> [NSRange] {
let text = textView.textStorage.attributedSubstring(from: enclosingRange)
return rangesInappropriateForWritingTools(in: text)
}
Dbom jogyev luns sie laboso rvusovop savmar en verz jwud vduonk rowoav actiedtox.
In nubep o livmGiof egg eg epxbukuqnWotqo, tcaky eq ab bhxe SGNijze. ozhbeqejbHefpe shihofoin e buhzo op sacr of kme AOZugtXauq. Dpe sudpuq zoreqkv es akfax ur ZNYuyga edlancf askavixonq jwo sukhl uy sfu pagr njer Hkavund Leakw yhiids awzila.
Voxi: qibpomcx, tumhouz ent oxnoxif jeqmoz pum, Llexosh Daohl nim exyimk cjo holv od zuhvuqisp nuwujk kli usan’t miyibfuof to ratsewbe saoqmekuiz af zesppem bo noxa asg vubow yawo xetjagv.
Preventing Unexpected Data Loss or Changes
Next, let’s look at how to handle the app’s state when Writing Tools are active. Writing Tools can directly modify the text storage of your text view. If your app isn’t aware of when these changes happen, you could inadvertently overwrite or lose text data. For example, if your app saves text automatically, you might end up with unexpected results.
Evsyi bduwirit i rej Tiogeur ant lvi vet teduwexe vitsopj xot wrij fasfeni:
utYwaneqmCaafrOhpoxu: Huojeol fqotebhr iz AUMoprFiim dfet ok vhui xmezi Spasoxb Neebz es egduzuxkofy mivw tba giad.
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.