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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T02:00:47+00:00 2026-05-25T02:00:47+00:00

Has anyone got any tips for this problem i’m facing. Its not complex, but

  • 0

Has anyone got any tips for this problem i’m facing. Its not complex, but there might be a cleaner way to do it in Core Data.

I have a table of data (or managed object) with date and a value. I present this data normally showing each day and the value for each day.

I want to group this in weeks, so aggregate all rows that have a week of a certain number.

Example: my data is currently display like this

  • Aug 5 | 5
  • Aug 4 | 18
  • Aug 3 | 8
  • Aug 2 | 3
  • Aug 1 | 10
  • Jul 31 | 2
  • Jul 30 | 1
  • Jul 29 | 7
  • Jul 28 | 6

etc etc

I want to display it like so:

  • Week 24 | 47
  • Week 23 | 13
  • Week 22 | 20

etc etc

I’m already using an NSFetchedResultsController, and would like to continue to use this if possible. I think this is where the difficulty lies. If i was just presenting a UITableView and a NSArray of data, this would be easy to add up my values and present the data.

However, NSFetchedResultsController seems to be tied to fetching results (obviously), so I guess I want to aggregate this data using a fetch so that I can hook it right into my table view as I do with the raw data.

Any suggestions?

Thanks

  • 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-25T02:00:47+00:00Added an answer on May 25, 2026 at 2:00 am

    I did this, but sort of an ugly way. But it works, and I needed to get it working quick…

    Because I wanted to continue to use my FetchedResultsController, and all the architecture I’d created to hook it up to my view controllers, it seemed easier to have distinct entities for my Weeks and Months.

    I know it goes against data storage principles by storing data that could be computed, but it was relatively easy to do.

    I have my UsageDay managed object, which is the majority of the data. I then have a UsageWeek and UsageMonth object.

    When I store a UsageDay object, from its date ivar, I calculate its weekOfYear and monthOfYear (and year) for both UsageWeek and UsageMonth.

    UsageWeek contains: weekOfYear, year, and an NSSet of the UsageDay objects it contains
    UsageMonth contains: monthOfYear, year, and an NSSet of the UsageDay objects it contains.

    I can then easily get a list of all UsageWeek’s, which has a set of 7 UsageDay objects – on which i call [usageWeek valueForKeyPath:@”usageDaySet.@sum.value”] – which gives my the total. Works fine.

    Feel free to openly criticize this design – I’m expecting it!!!

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

Sidebar

Related Questions

Has anyone else run into this problem before? I've got a method that calls
Has anyone got any experience in doing this? Specifically, I'd like to find out
Has anyone out there got a good set of instructions for building/compiling Ruby from
Has anyone got any advice or know of any frameworks for unit-testing of multithreaded
Has anyone got any idea why when I run the program, and go to
Has anyone got any idea to why doesn't the following work ? $file =
Has anyone got any idea how to implement a rudimentary semaphore in java without
Has anyone got any idea how or if it is possible to carry parentheses
I'm using webview in my xcode javascript refuses to run. has anyone got any
Has anyone got any success with integrating any of the existing DNN Store or

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.