Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6974403
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T17:13:59+00:00 2026-05-27T17:13:59+00:00

I have a simple TTTableViewController to represent a set of companies. I would like

  • 0

I have a simple TTTableViewController to represent a set of companies. I would like to sort the TableView alphabetically using sections and the letter selector on the right side of the TableView.

Is there an easy way to do this using Three20?

Currently I don’t have any separate datasource.

 - (void)createModel {

      NSMutableArray* itemsArray = [[NSMutableArray alloc] init];

      for(IDCompany* company in companies) {

           [itemsArray addObject:[TTTableSubtitleItem itemWithText:[company title]  subtitle:[company companyDescription]  URL:[company urlToDetailView]]];

      } 

     self.dataSource = [TTListDataSource dataSourceWithItems:itemsArray];
     [itemsArray release];

 }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T17:13:59+00:00Added an answer on May 27, 2026 at 5:13 pm

    for starters you should use TTSectionedDataSource. It supports sections by having 2 NSMutableArray – one for sections represented by an array of strings and the other by array of arrays with the items of the table for each section.

    Getting the letters is pretty simple too. UITableViewDataSource supports:

    - (NSArray*)sectionIndexTitlesForTableView:(UITableView*)tableView;

    and the base class in three20 supports extracting them by doing this:

    - (NSArray*)sectionIndexTitlesForTableView:(UITableView*)tableView {
       return [TTTableViewDataSource lettersForSectionsWithSearch:YES summary:NO];
    }
    

    The best solution for you would be to create a new DataSource and inherit it from TTSectionedDataSource, then implement something like this to build the sections:
    self.items = [NSMutableArray array];
    self.sections = [NSMutableArray array];

      NSMutableDictionary* groups = [NSMutableDictionary dictionary];
      for (NSString* name in _addressBook.names) {
        NSString* letter = [NSString stringWithFormat:@"%C", [name characterAtIndex:0]];
        NSMutableArray* section = [groups objectForKey:letter];
        if (!section) {
          section = [NSMutableArray array];
          [groups setObject:section forKey:letter];
        }
    
        TTTableItem* item = [TTTableTextItem itemWithText:name URL:nil];
        [section addObject:item];
      }
    
      NSArray* letters = [groups.allKeys sortedArrayUsingSelector:@selector(caseInsensitiveCompare:)];
      for (NSString* letter in letters) {
        NSArray* items = [groups objectForKey:letter];
        [_sections addObject:letter];
        [_items addObject:items];
      }
    

    For a complete working solution refer to the TTCatalog samples under the three20 source and in there you will find MockDataSource.m that has this code.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have simple HTML code with some JavaScript. It looks like: <html> <head> <script
I have simple jQuery Mobile site created using asp.net mvc 2 and uses basic
I have a simple table view which I have built using an example from
I'm trying to create a create a simple app where I have a TableView
I have simple WebView code like this: WebView wv = (WebView) findViewById(R.id.webview1); wv.loadUrl(http://en.wikipedia.org/wiki/Book); But
I have simple console application project for live video streaming using cross-platform libs on
I have simple Hello World C++ program (main.cpp): #include <iostream> using namespace std; int
I have simple list: <ul> <li>some text 1 </li> <li>some text 2</li> <li>some text
I have simple static lib in xcode with the only class test.h: @interface TestClass
I have simple regex \.*\ for me its says select everything between and ,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.