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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T04:53:27+00:00 2026-05-29T04:53:27+00:00

I have 3 entities like this: sorry that this image has a problem that

  • 0

I have 3 entities like this:

sorry that this image has a problem that the "day" relationship of "Week" entity should be to-many, there should be 2 arrows on the end of the relationship

sorry that this image has a problem that the “day” relationship of “Week” entity should be to-many, there should be 2 arrows on the end of the relationship

now here comes 2 questions.

1st. For any Day-Class (Customized subclass of NSManagedObject) objects, after I take care about its relationships like:

Week* aWeek;
Day *aDay;
[aWeek addDayObject:aDay];

then I can truely find the Day through the Week Entity’s relationship “day”,

but inversely, I found that the relationship “thisWeek” of the Day object “aDay” is still nil.

I’ve heard that after you creat your subclass of NSMangedObject, you got methods like

- (void)addXXXObject:(xxx)xxx

to help you deal with to-many relationships and would automatically take care with the inverse relationship.

but here it seems not. So do I have to deal with the inverse relationship by my self,

or if core data does provide, how can I make it automatically add the object on the inverse relationship?

2nd. Suppose there are many “Day”s with one “Week”, connected by their relationship,

what I want is , everytime the user delete one of the Days, we check whether if the Week still has some Days in relationship,

if it does, just let the user delete that Day,

if not, we also delete the “Week” object.

So what Delete Rule of the to-many relationship should I use?

I’m not so clear with these rules..

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-29T04:53:28+00:00Added an answer on May 29, 2026 at 4:53 am

    CoreData should actually take care of the inverse relationship as long a you defined it in both entities. See here.

    I would use nullify delete rule for the day->week relationship and cascade for week->day.
    When you delete the week, all days associated with it would get deleted too.
    When you delete a day, it will be removed from the week’s days. You cannot auto-delete the week when it has no days anymore. You can, however, observe the the week’s days and delete self if self.days.count == 0.

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

Sidebar

Related Questions

Hi the problem goes like this: I have in CoreData entities that have a
I have some Entities that look like this: @Entity public abstract class AbstractEntity{ @Id
I have data that looks like this: entities id name 1 Apple 2 Orange
I have a Linq to Entities query like this one: var results = from
Assume we have a method like this: public IEnumerable<T> FirstMethod() { var entities =
I have a collection of entities with an any-association, like this: public class CreatedLog
Should entities have behavior? or not? Why or why not? If not, does that
I have two entities Foo and Bar with a Many to Many relationship between
I have a model that looks like this: public interface IEntity { int Id
I have some entities that have a StringProperty and I would like to query

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.