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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T11:29:35+00:00 2026-06-11T11:29:35+00:00

Ok, so basically i have a core data database with customer information in. I

  • 0

Ok, so basically i have a core data database with customer information in. I have a searchbar also. I want it so i can select whether to search name, address, etc.etc.etc.

Here is the code i have at the moment:

 [sosdRequest setPredicate:[NSPredicate predicateWithFormat:@"(AccountCode contains[cd] %@           
AND %d>0) AND (CompanyName contains[cd] %@ AND %d>0) AND (Address1 contains[cd] %@ AND %d>0) 
AND (Address2 contains[cd] %@ AND %d>0) AND (Town contains[cd] %@ AND %d>0)  AND (County 
contains[cd] %@ AND %d>0) AND (Postcode contains[cd] %@ AND %d>0) AND (UserField01 
contains[cd] %@ AND %d>0) AND (UserField02 contains[cd] %@ AND %d>0) AND (UserField03 
contains[cd] %@ AND %d>0) AND (UserField04 contains[cd] %@  AND %d>0) AND (UserField05 
contains[cd] %@ AND %d>0)",searchBar.text, _searchAccountCodeOnly, searchBar.text, 
_searchNameOnly, searchBar.text, _searchAddress, searchBar.text, _searchAddress, 
searchBar.text, _searchTown, searchBar.text, _searchCounty, searchBar.text, _searchAddress, 
searchBar.text, _searchUser1, searchBar.text, _searchUser2, searchBar.text, _searchUser3, 
searchBar.text, _searchUser4, searchBar.text, _searchUser5]];

So with this, ‘_searchAddress’ ‘_searchNameOnly’ etc.etc. are integers. If i have say

_searchAccountCodeOnly = 0;
_searchNameOnly = 0;
_searchNumbers = 0;
_searchTown =  0;
_searchCounty = 0;
_searchAddress = 2;
_searchContact = 0;
_searchUser1 = 0;
_searchUser2 = 0;
_searchUser3 = 0;
_searchUser4 = 0;
_searchUser5 = 0;

my search will still return based on CompanyName. This is driving me insane and i’m about to run on my lunchbreak to clear my head a tad but if anyone has any ideas it 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-11T11:29:37+00:00Added an answer on June 11, 2026 at 11:29 am

    I don’t know if that actually works (and how effective Core Data/sqlite is with optimizing such a query), but to ignore one attribute in the query you probably mean

    (CompanyName contains[cd] %@ OR %d == 0)
    

    so that the subexpression evaluates to TRUE if the corresponding flag is zero.

    A better way would be to build an array of predicates with the queries that you actually need and then use

    [NSCompoundPredicate andPredicateWithSubpredicates:arrayOfPredicates];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I basically have the core data and the app working correctly except for the
Basically I have three different Core Data entities ( A , B , C
I have some calculated values in the core data database that I need to
I have a fairly straightforward data model for a Core Data app. Basically, I'm
I basically have 7 select statements that I need to have the results output
I have a core data application that uses an NSPredicate in one of its
I think I have a problem, maybe linked to a retain cycle in Core-Data.
I have a problem with Core Data which has left me at the end
Ok Guys, here's the situation I have. I'm using a UITableViewController with Core Data.
I have this issue with Core Data. I am creating a core-data-based application, for

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.