UIReferenceLibraryViewController hasDictionaryDefinition only works in Simulator on iPhone 5s

When I call this code:

NSString* word = @"hello";
bool response = [UIReferenceLibraryViewController dictionaryHasDefinitionForTerm:word];

      

... on iPhone 5 or higher, I get the correct value in "response" (bool depending on whether the variable "word" is defined in the local dictionary or not. It takes about 500ms to execute on the simulator.

However, when I call it on the iPhone 4, 5, 6, or 6+ simulator (but not 5), it immediately returns as false and logs the following:

 +[_UIDictionaryManager _availableDefinitionDictionaries] returned nil. 
Error: Error Domain=ASError Code=21 "The operation couldn’t be completed. 
(ASError error 21 - Unable to copy asset information)" 

      

The dictionary functionality should work on iOS 5+. I don't have iPhone 4s / 5/6/6 + devices to test this.

What's happening?

+3


source to share


2 answers


I think I eventually found the answer, which is that the message in the console is trying to say that the user doesn't have a dictionary installed.

The fact that

[UIReferenceLibraryViewController dictionaryHasDefinitionForTerm:word];

      

returns false if:



  • Word undefined
  • There are no dictionaries installed

It's really really useless. My strategy for handling all of this in my specific English-only use case:

  • If [UIReferenceLibraryViewController dictionaryHasDefinitionForTerm: word] returns true then call the real "definition function" and return.

  • However, if it returns false, then call dictionaryHasDefinitionForTerm with the word that must be defined in all English dictionaries, such as "or" or "word".

  • If "the" or "word" return true then dictionaries are installed, but this word is undefined in the installed dictionaries. Load the result from the word "/" to avoid repeating step 2, but do not save it forever because the user or the system might delete the dictionary - the whole dictionary system seems to be very flawed.

  • If "or" the word returns false, we can assume that the dictionaries are not installed. At this point, I call a function to present the definition of the original word (which is shown with "no definition" of course, but this is the only way for the user to access the "manipulate" dictionaries to set the dictionary!), Along with a dialog box explaining that the user needs to click "manage" and install the English dictionary if they need word definitions.

Long way from ideal, but not sure what else I can do in my case.

+2


source


Not sure if this really answers the question, but here's what you might be interested in knowing:

  • If you open UIReferenceLibraryViewController

    (even outside the application, for example from Safari) and click "Manage there" to display a list of dictionaries (even without downloading anything), the error will go away for the current simulator.
  • Resetting content and settings on the simulator returns an error - until you are # 1 again.
  • Oddly enough, on the device I constantly get YES

    in dictionaryHasDefinitionForTerm:

    , even if I then see "Uncertainty detection" in the controller.


Some of them should certainly be a bug :-)
I'm very curious to know if anyone has similar behavior in # 3 as it smells worse than clogging up in the logs.

+1


source







All Articles