Is it possible to programmatically get all keyboard letters for the selected language?
Yes, this will store and log them:
static inline NSArray * charactersInCharacterSet(NSCharacterSet *charSet) {
NSMutableArray * array = [NSMutableArray array];
NSData * data = [charSet bitmapRepresentation];
const char* bytes = [data bytes];
for (int i = 0; i < 8192; ++i) {
if (bytes[i >> 3] & (((unsigned int)1) << (i & 7))) {
[array addObject:[NSString stringWithFormat:@"%C", (unichar)i]];
}
}
return [NSArray arrayWithArray:array];
}
called like so:
NSCharacterSet * charSet = [[[NSLocale alloc] initWithLocaleIdentifier:@"sr_Cyrl_ME"]objectForKey:NSLocaleExemplarCharacterSet];
NSArray * chars = charactersInCharacterSet(charSet);
for (NSString *str in chars) {
NSLog(@"%@", str);
}
This will give you a tough time with some Asian country alphabets, but it's returning latin based language alphabets just fine. It will probably need to be rebuffed to handle some of the character based alphabets.
In fact, let me add some source material for you to take a look at this in more depth:
http://samplecodebank.blogspot.com/2013_06_09_archive.html
One more method, only because I knew I had this sitting around somewhere and it's a whole heck of a lot easier to implement, but this is limited to the section index titles of, for example, the index of a UITableView.
NSMutableArray *characters = [[NSMutableArray alloc] initWithArray:[[UILocalizedIndexedCollation currentCollation] sectionIndexTitles]];
for (id obj in characters) {
NSLog(@"%@", obj);
}