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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T14:37:39+00:00 2026-06-01T14:37:39+00:00

I have implemented the search method for a UITableView populate from a NSArray (mylist):

  • 0

I have implemented the search method for a UITableView populate from a NSArray (mylist):

- (void)filterContentForSearchText:(NSString*)searchText scope:(NSString*)scope{

    // reset array
    [self.filteredListContent removeAllObjects]; 

    // check the elements contained in the list
    NSString *cellTitle;

    for (cellTitle in myList){  //CHANGE HERE

        NSComparisonResult result = [cellTitle compare:searchText options:NSCaseInsensitiveSearch range:NSMakeRange(0, [searchText length])];
        if (result == NSOrderedSame){
            [filteredListContent addObject:cellTitle];
        }
    }
}

Now i would the same method for search a char in objectForKey:@"name" of a List of NSDictionary:

myList [0]:
{
        gender
        id
        name
        picture }
myList [1]
{
        gender
        id
        name
        picture }

I would something like this:

- (void)filterContentForSearchText:(NSString*)searchText scope:(NSString*)scope{

    [self.filteredFriendsList removeAllObjects]; 

    NSString *cellTitle;


        for (cellTitle in [[friendsList /* all objects */] objectForKey:@"name"]){

        NSComparisonResult result = [cellTitle compare:searchText options:NSCaseInsensitiveSearch range:NSMakeRange(0, [searchText length])];

        if (result == NSOrderedSame){
            [filteredFriendsList addObject:cellTitle];
        }

        }
}

Someone has some ideas?
Thank you.

  • 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-01T14:37:40+00:00Added an answer on June 1, 2026 at 2:37 pm

    Try this one:

    for (NSString *name in [friendsList valueForKey:@"name"])
    {
        if ([name isEqualToString:searchText]) [filteredFriendsList addObject:name];
    }
    

    The key here is the fact that valueForKey: method once invoked on an NSArray it calls valueForKey: on every of its objects.

    Ps. If you want a case insensitive comparison you can do so like:

    NSComparisonResult res = [searchTex caseInsensitiveCompare:name];
    if (res == NSOrderedSame) [filteredFriendsList addObject:name];
    

    EDIT: (To include solution for substring matching)

    if ([name rangeOfString:searchText].location =! NSNotFound) 
    { 
        // 'name' contains 'searchText' 
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In cellForRowAtIndexPath: method I have implemented gesture recognizer for long press, -(UITableViewCell *)tableView:(UITableView *)tableView
I have implemented a UITableView with search bar (and search display) - all works
In my website I have implemented search feature using full-text search. It works fine
In our desktop application, we have implemented a simple search engine using an inverted
I have already implemented a functionallity, when keeper automatically moves using breadth first search
I haven't implemented a search feature before and feel a bit stuck. I have
I have a search screen in my WPF application. The screen is implemented as
I have an app that includes a search feature. This feature is implemented by
I have a UITableView that was created from data coming from a mutable array.
I want to display search result on the screen, i have implemented in such

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.