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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T15:31:20+00:00 2026-06-08T15:31:20+00:00

I have a fairly large set of Core Data entities with a date property.

  • 0

I have a fairly large set of Core Data entities with a date property. I’m creating a report from the entities and need to find the report date range. There are ~1000 records within the report.

I’m thinking of getting the fetched objects array from my NSFetchedResultsController and sorting the array using date sort descriptor. Then getting the first and last object of that array to determine the date range. I seem to recall that date operations are expensive and am not sure if sorting an array that way, getting a 1000 element array back is a good idea.

Is there some other core data or predicate trick that I can use to query my core data stack to find an object with the minimum or maximum date?

Here’s the code that I’m currently using, but am wandering if there’s something faster and more efficient:

 NSSortDescriptor* sortDescriptor = [[NSSortDescriptor alloc] initWithKey:@"date" ascending:YES];
    NSArray* sortDescriptors = [NSArray arrayWithObject:sortDescriptor];

    NSArray* sortedDateArray = [NSMutableArray arrayWithArray:[fetchedResultsController.fetchedObjects sortedArrayUsingDescriptors:sortDescriptors]] ;       

    NSManagedObject* firstDateObject = [sortedDateArray objectAtIndex:0];  
    NSManagedObject* lastDateObject = [sortedDateArray lastObject];
  • 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-08T15:31:22+00:00Added an answer on June 8, 2026 at 3:31 pm

    No need to use a FetchedResultsController. Just use a simple FetchRequest, and take advantage of the aggregate functionality.

    The following document actually has an example of fetching based on the minimum date attribute of an entity.

    http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/CoreData/Articles/cdFetching.html#//apple_ref/doc/uid/TP40002484-SW6

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

Sidebar

Related Questions

I have fairly large set of data returned via AJAX from a page. This
I have a large data-set of emails sent and status-codes. ID Recipient Date Status
I have a fairly large script and am trying to find out, why $(document).on(
I have a problem retrieving items from a fairly large list. I can quickly
I have a fairly large CRUD winform app that is set up to display
We have a fairly large member site set up on AWS using a medium
I'm struggling to find a suitable solution to this. I have a fairly large
I have an application, and I am trying to set up a fairly large
I have a fairly large C++ application (on Windows, no other platforms planned), which
I have a fairly large Excel file. In this file there is a column

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.