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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T07:25:33+00:00 2026-05-18T07:25:33+00:00

I’ve been playing around with a search facility for my application table view for

  • 0

I’ve been playing around with a search facility for my application table view for a while now trying to get it working but i keep getting the same error in my console.

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: ' [NSCFDictionary rangeOfString:options:]: unrecognized selector sent to instance

I believe that this following section may be the problem I have tried passing some NSLog entries inside the if statement and it seems to get through it but the problem is when I click on the search bar and starting typing, the first letter I type calls the error and cancels my app.

Here is where the problem is

In View Will Appear “Food” Array is initialized as below:

 NSString *myDBnew =@"/Users/taxsmart/Documents/rw3app.sql";

database = [[Sqlite alloc] init];

[database open:myDBnew];

NSString *quer = [NSString stringWithFormat:@"Select category from foodcat"];

Food = [database executeQuery:quer];

//[database executeNonQuery:quer];

[database close];

Search bar delegate method where error is encountered:

(void) searchTableView 

{

   NSString *searchText = searchBar.text;

   NSMutableArray *searchArray = [[NSMutableArray alloc] init];

//   [searchArray addObjectsFromArray:Food];

    for(NSDictionary *dictionary in Food)
    {
         NSString temp1 = [dictionary objectForKey:@"category"];
         [searchArray addObject:temp1];
    }

     for (NSString *sTemp in searchArray)

     {

              NSLog(@"Value: %@",NSStringFromClass([sTemp class]));

         NSRange titleResultsRange = [sTemp rangeOfString:searchText options:NSCaseInsensitiveSearch];

           if (titleResultsRange.length > 0)

               [copyListOfItems addObject:sTemp];
     }  

      [searchArray release];

       searchArray = nil;
}

What should I do?

Please Help.

Please Suggest

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-18T07:25:34+00:00Added an answer on May 18, 2026 at 7:25 am

    It looks that result of database query (Food) is dictionary that contains dictionary. This code:

    for(NSDictionary *dictionary in Food)
    {
         NSString temp1 = [dictionary objectForKey:@"category"];
         [searchArray addObject:temp1];
    }
    

    can be replaced with:

    for(NSDictionary *dictionary in Food)
    {
         NSObject *ob = [dictionary objectForKey:@"category"];
         if([ob isKindOfClass: [NSString class]]) 
         {
            [searchArray addObject:ob];
         } 
         else if([ob isKindOfClass: [NSDictionary class]])
         {
            NSDictonary *dic1 = (NSDictionary*)ob;
            // ... at this point you can get the string for desired dictionary key 
            // or you can ignore it
         }
    }
    

    With this code we can be sure that only strings are put into searchArray.

    If you want to make full tree parsing for desired key ‘category’ then you should make some recursive function to search the dictionary.

    You can dump Food variable to console to see at which leaf is actually the result you are looking for. Put the break-point and into console type ‘po Food’.

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

Sidebar

Related Questions

No related questions found

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.