2011年12月27日星期二

Get List of Installed International Keyboards

Get List of Installed International Keyboards:
The NSUserDefaults object is typically used to save/restore your application related preferences, configuration data, etc – see Write and Read User Preferences for more information. In addition to application specifics, there is a system wide default list that is available to all applications, accessible using the class method standardUserDefaults in the NSUserDefaults object.
To get a list of the system wide settings:
NSDictionary* defaults = [[NSUserDefaults standardUserDefaults] dictionaryRepresentation];
NSLog(@"Defaults: %@", defaults);
A partial list of the output on my device follows:
Defaults: {
   AppleICUForce24HourTime = 0;
   AppleITunesStoreItemKinds =     (
       wemix,
       podcast,
       ...
   );
   AppleKeyboards =     (
       "en_US@hw=US;sw=QWERTY",
       "zh_Hant-HWR@sw=HWR",
       "emoji@sw=Emoji"
   );
   AppleKeyboardsExpanded = 1;
   AppleLanguages =     (
       en,
       "zh-Hant",
       fr,
       de,
 ...
}
As you can tell, the defaults returned above are contained within a dictionary object. The list of keyboards in the dictionary is stored as an NSArray object. To retrieve the array, simply request the object for the key “AppleKeyboards
NSArray *array = [[NSUserDefaults standardUserDefaults] objectForKey:@"AppleKeyboards"];
NSLog(@"Keyboards: %@", array);
The output of all the installed international keyboards looks as follows:
Keyboards: (
   "en_US@hw=US;sw=QWERTY",
   "zh_Hant-HWR@sw=HWR",
   "emoji@sw=Emoji"
)

没有评论:

发表评论