Is there a way to auto group/auto-section my UITableView
alphabetically? I have a huge array which is being displayed nicely, but it would be even better if I had the sections like in Contacts.app.
Best
–f
Is there a way to auto group/auto-section my UITableView
alphabetically? I have a huge array which is being displayed nicely, but it would be even better if I had the sections like in Contacts.app.
Best
–f
I have a pod just for this:
https://github.com/chrisladd/CGLAlphabetizer/
pod 'CGLAlphabetizer', '~> 0.1'
It creates a dictionary of arrays keyed by letters of the alphabet from a single array of objects and an arbitrary keyPath.
alphabetizedDictionary = [CGLAlphabetizer alphabetizedDictionaryFromObjects:anArray usingKeyPath:@"keyPath"];
So, assuming you had the model object that looked like this:
Your tableViewController implementation might look something like this:
Populated with every human who has gone to space:
First of All Define sections
then
After that filter by alphabets
i did the following:
AutoSectionTableViewDataSource.h
AutoSectionTableViewDataSource.m
and then in your code: