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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T09:50:32+00:00 2026-05-12T09:50:32+00:00

(Note: This is an extension of a previous question .) I am having some

  • 0

(Note: This is an extension of a previous question.)

I am having some difficulty implementing a SearchBar for fairly complex tableview. The tableView has multiple sections, two lines of text and an image. All the data is loaded from a plist and then put into sections by the initial letter of the value for the “Name” key. NSLog returns the following for my main dictionary “sectionedDictionaryByFirstLetter”:

sectionedDictionaryByFirstLetter:{
B = (
  {
    Name = "B...A Name Starting with B";
    Image = "ImageName1.png";
    Text = "Some Text";
  }
    );
C = (
  {
    Name = "C...A Name Starting with C";
    Image = "ImageName2.png";
    Text = "Some Text";
  }
    );
N = (
  {
    Name = "N1...A Name Starting with N";
    Image = "ImageName3.png";
    Text = "Some Text";
  },
  {
    Name = "N2...A Name Starting with N";
    Image = "ImageName4.png";
    Text = "Some Text";
  },
  {
    Name = "N3...A Name Starting with N";
    Image = "ImageName5.png";
    Text = "Some Text";
  }
  );
}

I want to filter the sub dictionaries by the value for the “Name” key. Can anyone recommend either how to go about this or some resources for learning how? I’ve been following the example in “Beginning iPhone 3 Development” but haven’t been able to translate it to my situation.
So if a user types “with N” in the search bar, I would like the new dictionary to appear as:

    filteredSectionedDictionaryByFirstLetter:{
N = (
  {
    Name = "N1...A Name Starting with N";
    Image = "ImageName3.png";
    Text = "Some Text";
  },
  {
    Name = "N2...A Name Starting with N";
    Image = "ImageName4.png";
    Text = "Some Text";
  },
  {
    Name = "N3...A Name Starting with N";
    Image = "ImageName5.png";
    Text = "Some Text";
  }
  );
}

Just to clarify, I have my searchBar installed in the view, I’m just having trouble making it functional. I’m currently toying with a custom method called – (void)handleSearchForTerm:(NSString *)searchTerm from the example in the book.

Thanks for the help!


Here’s the general structure of the data.

sectionedDictionaryByFirstLetter

Key   Value
B    Array of Dictionaries with Names beginning with B
      ....
C    Array of Dictionaries with Names beginning with C
      ...
N    Array of Dictionaries with Names beginning with N
     Item 1   Dictionary 1
     Item 2   Dictionary 2
     Item 3   Dictionary 3

          Dictionary 3
          {
          Name = "N3...A Name Starting with N";
          Image = "ImageName5.png";
          Text = "Some Text";
          }

I hope this is of some help. I’m still desperately looking for an answer to this problem.

Essentially, there is a primary dictionary who’s keys are the first letters of the items it contains. Within each first letter, there is an array of dictionaries that have a value for their “Name” key that begins with that letter.

  • 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-12T09:50:33+00:00Added an answer on May 12, 2026 at 9:50 am

    Okay, I finally answered my own question. Here is the code below. I mostly followed the example for searching an array in “Beginning iPhone 3 Development”. I had to edit it slightly to make it work for my problem. Here is my code:

    - (void)handleSearchForTerm:(NSString *)searchTerm
    {   
    NSMutableArray *sectionsToRemove = [[NSMutableArray alloc] init];
    [self resetSearch];
    for (NSString *key in self.keys)
    {
        NSMutableArray *array = [self.copyOfSectionedDictionaryByFirstLetter valueForKey:key];
        NSMutableArray *toRemove = [[NSMutableArray alloc] init];
        for (NSDictionary *name in array)
        {
            if ([[name objectForKey:@"Name"] rangeOfString:searchTerm options:NSCaseInsensitiveSearch].location == NSNotFound)
                [toRemove addObject:name];
        }
    
    if ([array count] == [toRemove count])
        [sectionsToRemove addObject:key];
    [array removeObjectsInArray:toRemove];
    [toRemove release];
    }
    
    [self.keys removeObjectsInArray:sectionsToRemove];
    [sectionsToRemove release];
    [self.tableView reloadData]; 
    }
    

    If you would like to see the full sample code to see how this is working, you can download from the “Beginning iPhone 3 Development” site here. It is the “sections” example.

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

Sidebar

Related Questions

Note This is not a REBOL-specific question. You can answer it in any language.
(NOTE: This question is not about escaping queries, it's about escaping results) I'm using
Moderator note: This question is not a good fit for our question and answer
Note: Originally this question was asked for PostgreSQL, however, the answer applies to almost
Note: This was posted when I was starting out C#. With 2014 knowledge, I
(Note: This is for MySQL's SQL, not SQL Server.) I have a database column
Note: this is a different problem to https - it's related to privacy security
Note: This is the opposite direction to most similar questions! I have an iPhone
Let's say I have a simple stored procedure that looks like this (note: this
Note that this function does not have a { and } body. Just a

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.