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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T10:15:45+00:00 2026-06-02T10:15:45+00:00

Hi I have a master array that populates the tableview and I have a

  • 0

Hi I have a master array that populates the tableview and I have a filtered array for the search results. Both of these work fine using the below method. My tableview and search display array is working well except for the below issue under this code block.

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

{

[self.filteredListContent removeAllObjects]; // First clear the filtered array.



for (product *new in parserData)
{

    //Description scope
   if ([scope isEqualToString:@"Description"]) 

    {
        NSRange result = [new.description rangeOfString:searchText options:(NSCaseInsensitiveSearch|NSDiacriticInsensitiveSearch)];

        if (result.location != NSNotFound)
        {
            [self.filteredListContent addObject:new];
        }
    }


    //Product scope
    if ([scope isEqualToString:@"Product"])

    {
        NSRange result = [new.item rangeOfString:searchText options:(NSCaseInsensitiveSearch|NSDiacriticInsensitiveSearch)];

        if (result.location != NSNotFound)
        {
            [self.filteredListContent addObject:new];
        }
    }
}

}

What I would like to achieve is this. I have an Item in the master array called LMD-2451 TD Professional 3D LCD Monitor. I can search for TD Professional, TD Pro, TD and it returns the correct item mentioned above using any case. However if I search Pro TD it doesn’t show any result. The problem I face is the user may not know the order the product title or description might be? So I would need to implement something that would do this logically. I am really stuck with what to do.

For reference

NSMutableArray *parserData; // Complete main full Array
NSMutableArray *filteredListContent; // Array for the Search-results

Any suggestions would be greatly appreciated.

  • 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-02T10:15:47+00:00Added an answer on June 2, 2026 at 10:15 am

    How about using componentsSeperatedByString:@" " on your search string to split it into (in your example) an array of 2 strings, @"Pro" and @"TD". Then loop through the array using the rangeOfString: check that all the components in the array are found in new.item.

    //Product scope
    if ([scope isEqualToString:@"Product"])
    {
        // Split into search text into separate "words"
        NSArray * searchComponents = [searchText componentsSeparatedByString: @" "];
        BOOL foundSearchText = YES;
    
        // Check each word to see if it was found
        for (NSString * searchComponent in searchComponents) {
            NSRange result = [new.item rangeOfString:searchText options:(NSCaseInsensitiveSearch|NSDiacriticInsensitiveSearch)];
            foundSearchText &= (result.location != NSNotFound);
        }
    
        // If all search words found, add to the array
        if (foundSearchText)
        {
            [self.filteredListContent addObject: new];
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a master array of length n of id numbers that apply to
I have two arrays that both look like this: Array ( [0] => Array
I have one master array and multi slave arrays and i need function that
I have a master detail Application in xCode. In Master View Controller an Array
I have a NSURL request that brings back an array of name and phone,
I have an array of arrays that is currently printing each object in the
I currently have an array that hold information that a user can do. I
I have a master product list that has a logical object structure: var myProducts
I have created Master/Detail grids and am able to load both grids properly. I
I have a method that takes a condition and item, from an array of

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.