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 6084461
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T11:31:29+00:00 2026-05-23T11:31:29+00:00

Edit: Updated code I’m trying to create a dictionary from table sections and then

  • 0

Edit: Updated code

I’m trying to create a dictionary from table sections and then the index list within each section, so the section letter would be the key… For the sections I have:

self.collation = [UILocalizedIndexedCollation currentCollation];

NSInteger index, sectionTitlesCount = [[collation sectionTitles] count];

NSMutableArray *newSectionsArray = [[NSMutableArray alloc] initWithCapacity:sectionTitlesCount];

NSString *alphabet = [[NSString alloc] initWithString:@"ABCDEFGHIJKLMNOPQRSTUVWXYZ"];

for (index = 0; index < sectionTitlesCount; index++) {
    NSMutableArray *array = [[NSMutableArray alloc] init];
    [newSectionsArray addObject:array];

    NSString *letter = [alphabet substringWithRange:NSMakeRange(index, 1)];
    [myDict setObject:newSectionsArray forKey:letter];

    [array release];
}

This crashes with:

'*** -[NSCFString substringWithRange:]: Range or index out of bounds'

Then for each letter I need to add the data for that section, I think this array would be the object for the section/letter key:

for (Data *myData in self.dataModel.datalist) {

    NSInteger sectionNumber = [collation sectionForObject:myData collationStringSelector:@selector(myName)];

    NSMutableArray *sectionData = [newSectionsArray objectAtIndex:sectionNumber];

    [sectionData addObject:myData];

}

Hope this makes sense! Thanks!!!

  • 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-23T11:31:29+00:00Added an answer on May 23, 2026 at 11:31 am

    Define your sections in an array

            sections = [NSArray arrayWithObjects:@"#", @"a", @"b", @"c", @"d", @"e", @"f", @"g", @"h", @"i", @"j", @"k", @"l", @"m", @"n", @"o", @"p", @"q", @"r", @"s", @"t", @"u", @"v", @"w", @"x", @"y", @"z", nil];
    

    implement the delegate methods

    - (NSInteger)numberOfSectionsInTableView:(UITableView *)tView {
        return [sections count];
    }
    
    
    - (NSArray *)sectionIndexTitlesForTableView:(UITableView *)tableView {
        return sections;
    }
    

    Then in - (UITableViewCell *)tableView:(UITableView *)tView cellForRowAtIndexPath:(NSIndexPath *)indexPath { you can get your subsection of the data

    NSArray *sectionArray = [myData filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"SELF beginswith[c] %@", [sections objectAtIndex:[indexPath section]]]];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

EDIT: Updated with suggestions from Bill Karwin below. Still very slow. I'm trying to
See updated input and output data at Edit-1. What I am trying to accomplish
Edit: Updated code. Now works well enough. Foreword. I am an OpenGL newb tasked
Edit: I've updated the code below so that it now works, thanks to Rob's
EDIT: Here is my updated code: #!/bin/sh files=`ls` if [ $# -ne 1 -o
EDIT: Heres the updated insert code. I'll try asserting it, but see if I'm
EDIT Updated code with solution I need to transcode amr to mp3, so i
EDIT: Updated code with new Pastebin link but it's still stopping at the info->citizens[x]->name
Edit: Updated code after changes I have a for loop that creates markers for
EDIT: Updated code to better reflect my problem this code returns 9 strings to

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.