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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T23:08:28+00:00 2026-06-15T23:08:28+00:00

I have the method below for filtering some results: Currently it does this: array:

  • 0

I have the method below for filtering some results:
Currently it does this:
array: alpha, apple, aries, bravo

type a:

alpha
apple
aries

type l (now al)

alpha

I wanted to do this:

new search:
type p=
alPha
apple

below is the code

thank you kindly in advance

-(void) filterResults:(NSString *)searchText{
    NSMutableArray *test = [NSMutableArray arrayWithArray:self.listContent];

    [self.filteredListContent removeAllObjects]; // First clear the filtered array.
        for (int i=0; i<[test count]; i++) {
            NSString *stringResult = [test objectAtIndex:i];
            NSComparisonResult result = [stringResult compare:searchText options:(NSCaseInsensitiveSearch|NSDiacriticInsensitiveSearch) range:NSMakeRange(0, [searchText length])];

            if (result == NSOrderedSame){
                [self.filteredListContent addObject:stringResult];

            }
        }
    [self.filteredListContent sortUsingSelector:@selector(localizedCaseInsensitiveCompare:)];//sort alphabetically
    NSLog(@"filtered results = %@",self.filteredListContent);
}
  • 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-15T23:08:29+00:00Added an answer on June 15, 2026 at 11:08 pm

    To find the letter anywhere in your string, replace this:

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

    with this:

    NSRange range = [stringResult rangeOfString:searchText];
    if (range.location != NSNotFound) {
        [self.filteredListContent addObject:stringResult];
    }
    

    Note that it will have to find all of the characters, in order.

    If you want to find any of the characters, then use rangeOfCharacterFromSet:.

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

Sidebar

Related Questions

I have this Function/Method for filtering out a Blacklist of words in an ARRAY()
Hi I have this method below which should insert values into my database. However
I have some classes as below, i have implemented the Equals(Object) method for almost
I have my attend method below currently in my controller. My question is how
I have this method below that gives me a count of products within a
I have the method below, which in my Blackjack app will get the value
I have a method below doing casting on a String according to the given
I have the below method which is meant to append information to a file
I have the below method: public String tryGoogleAuthentication(String auth_token){ ContactsService contactsService = new ContactsService(.....);
I have problem with android 4.0.3. I'm using the method below to get local

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.