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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T12:17:58+00:00 2026-05-26T12:17:58+00:00

I am presenting a list of managed objects where each has a timeStamp property.

  • 0

I am presenting a list of managed objects where each has a timeStamp property. I want to sort the list chronologically using the timeStamp property which i do with a NSSortDescriptor. But I also want to generate sections based on whole dates (one section for every day)

The following will give me one section based on second-differences which is too many sections:

NSFetchedResultsController *aFetchedResultsController = [[NSFetchedResultsController alloc] initWithFetchRequest:fetchRequest managedObjectContext:self.managedObjectContext sectionNameKeyPath:@"timeStamp" cacheName:@"PatientDetailViewCache"];

Is there a way to generate sections from the timeStamp property with the NSFetchedResultsController that are formatted like yy-MM-dd?

Thanks for any help

Christian

  • 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-26T12:17:59+00:00Added an answer on May 26, 2026 at 12:17 pm

    The easiest way is on your subclassed NSManagedObject create a property for a formatted date and sort using that property. There are many questions on SO with similar questions.

    Setting UITableView headers from NSFetchedResultsController

    A NSFetchedResultsController with date as sectionNameKeyPath

    But create a class wide NSDateFormater in the awakeFromFetch: like so:

    -(void)awakeFromFetch{
        dateFormater = [[NSDateFormatter alloc] init];
        [dateFormater setDateFormat:@"yy-MM-dd"];
        [super awakeFromFetch];
    }
    

    then in the accessor for that class property do something like this:

    -(NSString*)myprop{
        if(myprop==nil){
            myprop = [dateFormat stringFromDate:self.OTHERDATE];
        }
        return myprop;
    }
    

    Then your fetched results controller is:

    NSFetchedResultsController *aFetchedResultsController = [[NSFetchedResultsController alloc] initWithFetchRequest:fetchRequest managedObjectContext:self.managedObjectContext sectionNameKeyPath:@"myprop" cacheName:@"PatientDetailViewCache"];
    

    Then it will return the formatted date and sort based on that.

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

Sidebar

Related Questions

I have an ItemsControl presenting a list of buttons. Each button has an image
I'm using a pretty standard recipe for presenting ModalViewControllers in my iPhone apps, but
I have a list of items, which I will be presenting to the user
When a list becomes very large , presenting it in a UI raises a
How do I remove duplicates from a list, while preserving order? Using a set
When presenting a fixed list of countries in a ComboBox control, with no free
I'm having an issue with correctly presenting items in an unordered list. The labels
I want to dynamically add items to a class, but someone may have to
I have a list of 100 entries that I want to process with multiple
Has anyone managed to create a CTE in SQL Server's T-SQL that also includes

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.