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

The Archive Base Latest Questions

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

I have a core data model with blog groups, blogs, and posts. A blog

  • 0

I have a core data model with blog groups, blogs, and posts. A blog group has a to-many relationship to blogs, and each blog has a to-many relationship to posts. A post has an attribute “hasBeenRead.” Both the blog and the blog group have a attributes “numberUnreadPosts.”

I’d like to know the best practice for propagating the number of unread posts up through each relationship. For instance, if I read a post, I’d like to decrease the number of unread posts by one in both the blog and the blog group. 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-16T07:40:19+00:00Added an answer on May 16, 2026 at 7:40 am

    There are a couple of ways to do this.

    KVO observer

    Your BlogGroup could watch for changes on the Blog entity -numberUnreadPosts property and when it changes it can update itself.

    Likewise, your Blog can watch for changes on the Post entity -hasBeenRead property and when it changes it can update itself which will propagate up to the BlogGroup.

    The problem with this design is that it assumes that the BlogGroup and Blog entities are both in memory (because you would turn the observer on in the -awakeFromFetch method). This may not always be the case and I find it best not to rely on that situation.

    Propagate the update

    When a Post changes the -hasBeenRead property you can override the setter and have it call it’s parent (Blog) and tell it about the change. Blog would then update it’s own unread count and tell the BlogGroup that it has updated.

    This design is far more consistent and is unlikely to fail. However it can have unforeseen consequences because of the ripple. When you change a post a number of objects get fetched into memory to be updated.

    Or don’t worry about it

    A third option is that only the post actually has the value. You could then produce a convenience method on both the Blog and the BlogGroup that merely counts the unread from the objects below.

    This is pretty simple to do but it is not an observable property so may not work in your design.

    The design of your application will determine which design works better for you. If you know that the BlogGroup and Blog will always be realized when you are working with a post then option one is a better solution imho.

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

Sidebar

Related Questions

I have core data model with two entities that have a many-to-many relationship with
I have a core data model which includes an entity with a to-many relationship.
I have a Core Data model setup like so: Blockbuster Entity To-Many relationship to
I have a Core Data Model consisting of a Trail that has-many Locations. I
I have a core data model defined as follows: A User has many events.
In my core data model I have a Person entity that has a to
In my Core Data model I have two entities: List and Patient. List has
I have an attribute called phoneNo in my Core Data model, an integer16 ,
I have created a core data model that has two entities which have a
I have a core data model that has two entities, Bid and Result. I

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.