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

  • Home
  • SEARCH
  • 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 8260877
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T03:12:24+00:00 2026-06-08T03:12:24+00:00

I am currently creating a TableView application using sqlite and thus far, it works

  • 0

I am currently creating a TableView application using sqlite and thus far, it works as intended. The first view is a listing of all states in the United States and returns them in alphabetical order in one section called “States”. My question is…How do I create an alphabetical sectioned list for this data? In other words, create a section named “A” that contains states Alabama, Alaska, Arizona, Arkansas. A section named “C” that would contain California, Colorado, Connecticut. It would basically comb the results, looking for the first letter in each state and if there is a match, place that state in the appropriate section.

I have come across some articles that describes how to do this but not relative to sqlite. Any help would be greatly appreciated!!

Thank you in advance!

  • 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-06-08T03:12:26+00:00Added an answer on June 8, 2026 at 3:12 am

    One approach could be to feed a structure that is an array of array. Each section of the array will contain an array of States that match the same first letter of states. Work on this structure then to implement the datasource and delegate methods.

    As it happen to me to do something very similar, here is a code snippet to feed the structure (self.browserContents). I hope it will help:

    BrowserContents *bc = [[BrowserContents alloc] init];
    
    // Create an array to hold the sub arrays
    NSInteger sectionCount = [bc getNumberOfCategories]; 
    NSMutableArray *sectionsArray = [NSMutableArray arrayWithCapacity:sectionCount];
    
    // Iterate over each section, creating each sub array 
    for (int i = 0; i < sectionCount; i++) {
        NSMutableArray *singleSectionArray = [NSMutableArray arrayWithCapacity:1];
        [sectionsArray addObject:singleSectionArray]; 
    }
    
    // Fill up each section
     NSMutableArray *contentsTemp = bc.contents;
     for (BrowserStateItem *item in contentsTemp) {
            [(NSMutableArray *)[sectionsArray objectAtIndex:[item categoryId]] addObject:item];
     }
    
    // Iterate over each section array to sort the items in the section 
    UILocalizedIndexedCollation *indexedCollation = [UILocalizedIndexedCollation currentCollation];
    for (NSMutableArray *singleSectionArray in sectionsArray) 
    {
            NSArray *sortedSection = [indexedCollation sortedArrayFromArray:singleSectionArray collationStringSelector:@selector(name)];
            [self.browserContents addObject:sortedSection];
    }
    

    Note:
    BrowserContents is a class that should contain the list of all states, the number of categories and id of the category it should belong to (e.g: A->1, B->2 etc… supposed you have states that start with A and B). Last check the book Professional iPhone and iPad Database Application Programming. This has been a great ressource to understand database programming in iOS.

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

Sidebar

Related Questions

I am currently creating my first project using Google App Engine in Eclipse. For
im currently creating a graph for an app, using coreplot and have a problem
I am currently creating an application for compiling multiple java projects in one go
I am creating a favorite pages menu in my tableview application, where users can
I'm currently creating both the client and server app using ActiveResource for web servicing.
I am currently creating a frontend editor for wordpress using TDO Mini Forms and
Im currently creating a uninstallation application which deletes the application folder. The problem is
Currently creating a VOIP application for Android and I was wondering is there any
I'm currently creating my first custom theme for Tumblr and I can't find any
I'm currently creating rspec test cases for a Rails 2.3 application. The problem I'm

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.