I'm currently trying to implement a UITableView
with a delegate and data source that replicates, as closely as possible, the functionality found the ABAddressBookUI
framework's ABPeoplePickerNavigationController
class, but with the added ability to select multiple contacts at once (as indicated by adding/removing an accessory view to the appropriate UITableViewCell
).
Everything is working fine, with the exception of providing localized "section index titles" (the letters that appear in the scroll overlay to the right of the screen) for the UITableView
, as should be returned by the data source method:
- (NSArray *)sectionIndexTitlesForTableView:(UITableView *)tableView
Obviously, I could just return an NSArray
containing the NSStrings
A, B, C ...Z, but I'd ideally like this method to return an array of all of the (uppercase, where applicable) letters of the alphabet of the current locale.
One promising lead was:
[[
NSLocale
currentLocale ] objectForKey:@"NSLocaleExemplarCharacterSet" ]
But I can't find any significant documentation on this and it returns an NSCharacterSet
, from which I've been unable to extract the actual characters (if I could do that, then NSCharacterSet's capitalizedLetterCharacterSet
could also be a promising starting point).
I've also run an otool -tV
on the AddressBookUI
framework, which revealed a call to the function ABAddressBookCopySectionIndices()
, into which an ABAddressBookRef
can be passed to obtain exactly what I'm looking for… a CFArray of the localized alphabet. However, it's a private function, so I can't use it in my app.
So, does anybody know whether Cocoa Touch supports this functionality? And, if not, are there any ideas as to how ABAddressBookCopyIndices()
is working its magic? I suspect the International Components for Unicode library may well hold the key, but I'm not (as yet) familiar with its capabilities...