2

Regarding the spell checking in iOS, it's possible to tell the checker to ignore a word (or learn a word),

https://developer.apple.com/documentation/uikit/uitextchecker

func ignoreWord(String)
Tells the receiver to ignore the specified word when spell-checking.
- Apple doco

Say I have a UITextView which opens. I want spell checking On.

I know the user may type "fattie" which would get the red underline.

How do I tell that text view in that instance, to, ignore "fattie" ?

An obvious use case ...

User is typing in "@tag" type friends; in our data of course we know what all the tags are, it's absurd they get marked as spelling errors.

It seems incredible one can't just say "don't underline these words - - list".

Code example ....

So we have

var t: UITextView

and then, there must be "some way" to:

yourTextView.something->something.textChecker.ignoreWord("fattie"

.. some way to get to the text view's textChecker instance! How ?!?!

Community
  • 1
  • 1
Fattie
  • 27,874
  • 70
  • 431
  • 719
  • Possible duplicate: https://stackoverflow.com/questions/7762476/uitextview-custom-spelling-and-autocorrect – Sweeper Jan 28 '20 at 17:38
  • @Sweeper , thanks, but it's really unrelated. That's about **creating your own** spell-check engine - indeed the answer explains how to do that. This question is totally unrelated. I want to know how to use the function stated, in Apple's spell-checker, when using, a specific iOS component. Cheers – Fattie Jan 28 '20 at 17:41
  • @LeoDabus - actually oddlly, check the answer I'm adding ! – Fattie Jan 28 '20 at 17:44

1 Answers1

1

Partial answer: I just stumbled on to that, bizarrely, you can just call

    UITextChecker.learnWord("fattie")
    UITextChecker.learnWord("blahdee")

from, apparently, just anywhere in an app.

However this raises many issues,

• How to call the 'ignore' one, which seems better

• That one still makes the user tap the annoying, stupid, "in quotes" OK box in the suggestions bar - it seems to have not really "learned" anything

• Disturbingly, I think this goes for the "WHOLE PHONE". I only want it in that instance of the user using that text view.

A mystery!

Fattie
  • 27,874
  • 70
  • 431
  • 719
  • 1
    sorry for the misunderstanding – Hazem Mohamed Jan 28 '20 at 17:49
  • You can learn the word when the text view starts editing, and unlearn it when it stops editing to overcome the problem of learning the word for the whole phone, right? – Sweeper Jan 28 '20 at 18:01
  • @Sweeper , yes, that's an excellent point - but unfortunately my "point 2" is a disaster, that's why "ignore" is needed ... strange issue! I assumed it would be straightforward. There must be a way to get to the instance of the checker, which, the view is using.. – Fattie Jan 28 '20 at 18:04
  • https://developer.apple.com/documentation/uikit/uitextchecker/1621032-ignoredwords try `textChecker.ignoredWords = ["fattie","blahdee"]` – Leo Dabus Jan 28 '20 at 18:17
  • ahhh! but I *don't have* textChecker !!!!!!!! that's the disaster! it has to be like yourTextView.something.something->something.textChecker ... I guess! – Fattie Jan 28 '20 at 18:27
  • @LeoDabus - my code would simply be `var t: UITextView` .. or in reality a `UITextView` subclass – Fattie Jan 28 '20 at 18:50