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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T13:30:46+00:00 2026-05-15T13:30:46+00:00

I am building a pretty complex predicate in several iterations, and want to supply

  • 0

I am building a pretty complex predicate in several iterations, and want to supply the matching values right away in the predicate.

Instead of:

[NSPredicate predicateWithFormat:@"departmentName like[c] %@"];

I want to do:

NSString *str = [NSString stringWithFormat:@”departmentName like[c] ‘%@'”, departmentName];
[NSPredicate predicateWithFormat:str];

Since this is a dumb substitution, I guess it’s possible to “hack” the predicate accidently by entering garbage.

I couldn’t find anything that would “magically quote” that value for me.

Reason is, that I need to build up a complex predicate in several iterations, so I have to construct a big predicate string. Templates don’t work with SUBQUERY. So I need to provide the values right away in the string, since I don’t want to make 20 different predicate initializations depending on how many values I have for the predicate format.

  • 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-15T13:30:46+00:00Added an answer on May 15, 2026 at 1:30 pm

    Use NSComparisonPredicate directly, and bypass the predicate format issues.

    NSPredicate *fetchPredicate = [NSComparisonPredicate predicateWithLeftExpression:[NSExpression expressionForKeyPath:@"departmentName"]
                                                                     rightExpression:[NSExpression expressionForConstantValue:searchTerm]
                                                                            modifier:NSDirectPredicateModifier
                                                                                type:NSLikePredicateOperatorType
                                                                             options:0];
    

    Have a read through the Predicate Programming Guide “Creating Predicates Directly in Code”, and check the class reference for NSComparisonPredicate

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

Sidebar

Related Questions

Right now I'm building a personal site/blog and have pretty much got it they
Folks, I'm building a pretty standard workflow that I want exposed via a WCF
I'm building a pretty basic HTML table creator/editor (based on a designMode iframe) at
I am building a pretty basic form app. I can get a list of
I'm working on building a pretty simple site mainly as an exercise in learning
I'm in the middle of building a pretty big site using asp.net (forms if
I'm looking at building a Rails application which will have some pretty large tables
I am pretty new to database design. I am building a small asp.net mvc
Well, lets say I'm building ActiveMQ based chat application. It's pretty simple. Having only
I am building a Django application that is a pretty basic blog, so far

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.