5

I am trying to make a crossword app for IOS but i Don't know that how to check if a string is valid english word or not.

How can i check it. Is there any API or online facility to check it. Thanks in Advance

memmons
  • 40,222
  • 21
  • 149
  • 183
Johnykutty
  • 12,091
  • 13
  • 59
  • 100

2 Answers2

6

Easy to do in iOS5 using the UIReferenceLibraryViewController class' +dictionaryHasDefinitionForTerm: method.

A UIReferenceLibraryViewController object provides a dictionary service to look up the definition of terms. You create and initialize a reference library view controller using the initWithTerm: method. You pass the term to define as the parameter to this method and the definition is displayed. You can present this view controller modally or as part of another interface. On iPad, you can set the reference library view controller as the content view controller of a UIPopoverController object. Optionally, use the dictionaryHasDefinitionForTerm: class method to check if a definition is available for a given term before creating an instance—for example, use this method if you want to change the user interface depending on whether a definition is available.

memmons
  • 40,222
  • 21
  • 149
  • 183
0

There is no API for this.

In order to do this, you will need to have a dictionary file (text file or database) in your application bundle. One of the faster ways to check will be to load the dictionary into memory when the application launches so you don't have to read the file for each word. This may be overkill if you simply want hardcoded crosswords, but if you are randomly generating them then this is a must.

FreeAsInBeer
  • 12,937
  • 5
  • 50
  • 82
  • -1 - there may (or may not) be a Dictionary API in iOS5 (I can't say with certainty, since I haven't looked). However, I do know that there are a multitude of different dictionary APIs available online. One of which is Wordnik (http://wordnik.com), which I have used in my own apps to define words. – Jasarien Nov 04 '11 at 15:46
  • *Answerbot*: Please extrapolate. *Jasarien*: Why would you want to force your user to be connected to the internet to check the validity of a word? Since the OP refers to a crossword puzzle, I'm assuming he doesn't want the user to have to wait for possibly several seconds after playing each word. A common request for crossword games is a timer, and having to wait for each word to be verified will not only affect the total play time, but also be annoying to the user. I disagree with both downvotes (especially Answerbot, who explained his reasoning so well), but I respect your opinions. – FreeAsInBeer Nov 05 '11 at 13:10