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

  • Home
  • SEARCH
  • 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 8062295
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T10:37:09+00:00 2026-06-05T10:37:09+00:00

I have a core data entity, Client , which has a discount property. I

  • 0

I have a core data entity, Client, which has a discountproperty. I want to fetch the the client with the smallest discount.

I am using the following NSPredicate:

[NSPredicate predicateWithFormat:@"@min.discount"];

However, I am getting the following error:

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Unable to parse the format string "@min.discount"'

What am not doing right?

  • 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-05T10:37:11+00:00Added an answer on June 5, 2026 at 10:37 am

    I don’t think NSPredicate has support for functions like this unless it is part of a boolean predicate expression (i.e. involving things like “greater than”).

    You should read this CoreData documentation which gives some examples, specifically using max as an example:

    There are a number of steps to follow to create and use the expression
    description.

    First you need to create expressions (instances of NSExpression) to represent the key-path for the value you’re interested in, and to
    represent the function you want to apply (such as max: or min:):

    NSExpression *keyPathExpression = [NSExpression expressionForKeyPath:@"salary"];
    NSExpression *maxSalaryExpression = [NSExpression expressionForFunction:@"max:"
                                                      arguments:[NSArray arrayWithObject:keyPathExpression]];
    

    For a full list of supported functions, see expressionForFunction:arguments:.

    You then create the expression description and set its name, expression, and result type.

    The name is the key that will be used in the dictionary for the return value. If you want to retrieve multiple values—such as the
    largest and the smallest salaries in an Employee table—the name of
    each expression description must be unique for a given fetch request.

    NSExpressionDescription *expressionDescription = [[NSExpressionDescription alloc] init];
    [expressionDescription setName:@"maxSalary"];
    [expressionDescription setExpression:maxSalaryExpression];
    [expressionDescription setExpressionResultType:NSDecimalAttributeType];
    

    Finally, you set the request’s properties to fetch just the property represented by the expression:

    [request setPropertiesToFetch:[NSArray arrayWithObject:expressionDescription]];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Core Data entity which needs a gender property. I just need
I have a Core Data entity which has a date attribute. I would like
I have a Core Data Entity which has three properties startDate, endDate and duration.
I have a core data stack which contains an entity called 'Client'. Each client
I have a core data entity which has an exclusive one to many relationship
I have a Core Data entity, bid, which has a relationship to many items,
I have an Core Data Entity with a number of attributes, which include amount(float),
I have a document-based Core Data app. My main Core Data entity has several
I have an entity in core data that has 2 Attributes. One that is
In my core data model I have a Person entity that has a to

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.