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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T20:35:06+00:00 2026-06-18T20:35:06+00:00

I am trying to search my Core Data database, returning a very specific set

  • 0

I am trying to search my Core Data database, returning a very specific set of records.

My model looks something like this:

firstName (NSString)
lastName (NSString)
dateOfBirth (NSDate)
updatedAt (NSDate)
weight (NSNumber)
height (NSNumber)

I want to get a list of users with unique firstName, lastName, and dateOfBirth values, but only return the full record of each of these users with the latest updatedAt value.

So, for database like:

firstName: Jim, lastName: Brown, dateOfBirth: 1/1/2012, updatedAt: 1/1/2012, weight: 100, height: 100
firstName: Jim, lastName: Brown, dateOfBirth: 1/1/2012, updatedAt: 2/1/2012, weight: 120, height: 100
firstName: Joe, lastName: Smith, dateOfBirth: 1/1/2012, updatedAt: 1/1/2012, weight: 100, height: 100
firstName: Joe, lastName: Smith, dateOfBirth: 2/1/2012, updatedAt: 1/1/2012, weight: 100, height: 100

I would get an array:

firstName: Jim, lastName: Brown, dateOfBirth: 1/1/2012, updatedAt: 2/1/2012, weight: 120, height: 100
firstName: Joe, lastName: Smith, dateOfBirth: 1/1/2012, updatedAt: 1/1/2012, weight: 100, height: 100
firstName: Joe, lastName: Smith, dateOfBirth: 2/1/2012, updatedAt: 1/1/2012, weight: 100, height: 100

I know I could run around performing a whole bunch of different filtering operations, but I was wondering if there were any “shortcuts” that could help this. I could use [fetchRequest setReturnsDistinctResults:YES] if I wasn’t interested in getting the updatedAt value, but this would return essentially all of the records if I include updatedAt in the properties to fetch. I’m worried about loading the entire database into an NSArray because it could be very large (>10,000 records).

  • 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-18T20:35:07+00:00Added an answer on June 18, 2026 at 8:35 pm

    First, I think you should revise your data model. First name, last name and birthdate are just not enough to substitute unique ids (out of 10.000s of records) reliably.

    Second, you should therefore create a Person entity and use the same record of this entity to associate with some kind of Event that carries the updated date attribute.

    With this much more robust structure in place, your query becomes trivial. You just fetch all persons. For each person you select the most recent event if needed.

    Event *latestEvent = [person.events valueForKeyPath@"@max.updated"];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to search a MongoDB database filtering on a specific data item.
I'm trying to use BuildExcerpts in django sphinx. My view looks something like this:
I am trying to make a compound predicate for my core data search. So
I have a Core Data model like so: ArticleCache: - NSString *link And I
I'm trying to accelerate this database search application with CUDA, and I'm working on
I'm trying to implement search in my app. There are two Core Data entities,
I am trying to retrieve results from search bar text in Core Data on
I've got a Core Data property that I'm trying to set at runtime, with
Im trying to search two of the fields in my table. (Database table contains
I'm trying to search through a Word document and replace a specific string (Using

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.