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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T05:23:40+00:00 2026-05-18T05:23:40+00:00

Say I have a Core Data entity called Person. How would I get an

  • 0

Say I have a Core Data entity called Person. How would I get an NSArray of Persons whose properties match certain values? For instance someone of a particular age, height, or weight… or someone with a whose height,weight and age are specific values…

Can I use an NSPredicate like so:

NSPredicate *pred = 
[NSPredicate predicateWithFormat:
@"(age == 25) OR (height_in_cms == 185) OR (age == 30 AND height_in_cms == 170 AND weight_in_kgs == 80)"; 
// All properties are NSNumber
  • 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-18T05:23:40+00:00Added an answer on May 18, 2026 at 5:23 am

    I’m not an expert on the syntax for predicateWithFormat:, but you have the basic gist. You can find details on the format in Apple’s Predicate Programming Guide. If you’re asking what to do with the predicate once you have it, here is a snippet that shows you the steps:

    // Create a fetch request.
    NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init];
    
    // Set the entity for the fetch request.
    NSEntityDescription *entity = [NSEntityDescription entityForName:@"EntityName" inManagedObjectContext:managedObjectContext];
    [fetchRequest setEntity:entity];
    [entity release];
    
    // Set the predicate for the fetch request.
    [fetchRequest setPredicate:predicate];
    
    // Perform the fetch.
    NSError *error;
    NSArray *array = [managedObjectContext executeFetchRequest:fetchRequest error:&error];
    [fetchRequest release];
    

    If you want the results to be sorted, you can pass an array of sort descriptors to the fetch request using setSortDescriptors: prior to executing the fetch.

    • 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 called Item and it represents an item in
Say you have a Core Data object called Workshop. It has a to-many relationship
I have a Core Data model setup like so: Blockbuster Entity To-Many relationship to
I've got a Core Data entity called Card which has a relationship info to
Lets say I have a core data model like this one: Item attributes: name
Say I have core data objects of type obj that has a property propertyA
Using Core Data. Let's say we have models for Team and Player. Assume: -Each
Say you have a couple of Core Data entities .. Student and Exam. These
Say you have an application divided into 3-tiers: GUI, business logic, and data access.
Say I have an parent entity, each of which have a number of children.

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.