Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Spellcheck word.py
# coding: utf-8
from objc_util import ObjCClass
UITextChecker = ObjCClass('UITextChecker')
def check_word(word, lang='en_US'):
c = UITextChecker.new().autorelease()
check = c.rangeOfMisspelledWordInString_range_startingAt_wrap_language_
misspelled_range = check(word, (0, len(word)), 0, False, lang)
return (misspelled_range.location != 0)
test_words = ['foo', 'bar', 'baz', 'quuz', 'cat', 'dog']
for word in test_words:
print '%s: %s' % (word, check_word(word))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.