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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T14:11:51+00:00 2026-05-14T14:11:51+00:00

I have a UITableView containing names that I would like to group (and sort)

  • 0

I have a UITableView containing names that I would like to group (and sort) by the first letter (similar to the Address Book application). I am currently able to match any section (‘A’-‘Z’) using:

// Sections is an array of strings "{search}" and "A" to "Z" and "#".
NSString *pattern = [self.sections objectAtIndex:section];
NSPredicate *predicate = nil;

// Ignore search pattern.
if ([pattern isEqualToString:@"{search}"]) return nil;

// Non-Alpha and Non-Diacritic-Alpha (?).
if ([pattern isEqualToString:@"#"]);

// Default case (use case and diacritic insensitivity).
if (!predicate) predicate = [NSPredicate predicateWithFormat:@"name beginswith[cd] %@", pattern];

// Return filtered results.
return [self.friends filteredArrayUsingPredicate:predicate];

However, matching for the ‘#’ eludes me. I tried constructing a REGEX match using:

[NSPredicate predicateWithFormat:@"name matches '[^a-zA-Z].*'"];

But this fails for diacritic-alpha (duplicate rows appear). Any ideas would be greatly appreciated! 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-14T14:11:51+00:00Added an answer on May 14, 2026 at 2:11 pm

    I typically use UILocalizedIndexedCollation and a custom NSArray category to deal with this. I also have a wrapper (decorator) for UILocalizedIndexedCollation that will include the search symbol and handle the offsets for this for you.

    The implementation of my NSArray category is here: http://gist.github.com/375409

    So, given an array of objects objects with a name property, I would create an indexed array like so:

    UILocalizedIndexedCollation *collation = [UILocalizedIndexedCollation currentCollation];
    NSArray *indexedObjects = [objects indexUsingCollation:collation withSelector:@selector(name)]; // returns an array of arrays
    

    Its important to note that UILocalizedIndexedCollation already deals with the logic of indexing and grouping your objects in a localized manner, so there is no need to reinvent the wheel here.

    My collation decorator that deals with the search icon can be found in this github gist.

    A more detailed tutorial on using it can be found on my blog.

    In this case, you would simply pass in an instance of my collation wrapper instead of UILocalizedIndexedCollation in the example above.

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

Sidebar

Related Questions

I have a view containing a UITableView. Above the table I'd like to display
I have a storyboard setup as a Tabbed Application with first view controller containing
I am populating a UITableView with cells containing a UIImageView subview. I would like
I have a View Controller containing a UITableView that used an NSMutableArray to determine
On my iphone app, I have a UITableView in edit mode, containing custom UITableViewCell.
I have a UITableView that lists comments from various users. I save all of
I have a UITableView which contains names in each row alongwith images for each
I have a UITableView with cells containing variable-height UILabels. I am able to calculate
I have a UITableView with custom cells. The cells containing one UITextView each and
I have a UITableView that is populated with cells of a variable height. I

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.