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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T14:58:41+00:00 2026-05-15T14:58:41+00:00

Core Data is throwing me for a loop. I have two objects:, Card and

  • 0

Core Data is throwing me for a loop. I have two objects:, Card and CardSet, which are in a many-to-many relationship with each other, i.e. you could have cards 1, 2, and 3 in CardSet A and cards 2, 4, and 5 in CardSet B.

I am trying to set up my delete actions so that:

  1. If I delete a Card, it is removed from all CardSets to which it belongs. (i.e., delete Card 2, then CardSet A = {1, 3} and CardSet B = {4, 5})
  2. If I delete a CardSet, then all of the cards in the set are deleted EXCEPT those which belong to another set. I.e. delete CardSet A, then CardSet B remains {2, 4, 5}.

My data structure has two relationships which define this many-to-many relationship: CardSet.cards and Card.cardSets. The delete action for CardSet.cards is cascade (so if I delete a CardSet, all of its cards are deleted) and my delete action for Card.cardSets is null (so if I delete a single card, the cardSets are not nuked as well).

However, with this current setup if I delete CardSet A, then CardSet B remains {2, 4, 5} BUT Card 2 has actually been deleted from the data store which leads to a core data error when trying to access the CardSet. What should I be doing here to make sure that cards are not deleted if they are still being held by another CardSet?

  • 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-15T14:58:41+00:00Added an answer on May 15, 2026 at 2:58 pm

    You want to set Card.cardsets to deny instead of null. That way, the card will not be removed until it is no longer related to any CardSet.

    From the Core Data Programming Guide

    Deny

    If there is at least one object at the
    relationship destination, then the
    source object cannot be deleted.

    For
    example, if you want to remove a
    department, you must ensure that all
    the employees in that department are
    first transferred elsewhere (or
    fired!) otherwise the department
    cannot be deleted.

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

Sidebar

Ask A Question

Stats

  • Questions 523k
  • Answers 523k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Refer to this forum post. Basically, you need to go… May 16, 2026 at 9:37 pm
  • Editorial Team
    Editorial Team added an answer A message queue should be suited for this task. You… May 16, 2026 at 9:37 pm
  • Editorial Team
    Editorial Team added an answer select e.EmpID,e.EmpName,r.Sal,r.PaidYear from @emp e inner join @Remu r on… May 16, 2026 at 9:37 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

My Core Data model contains an entity, Shape, that has two self-referential relationships, which
Using Core Data. Let's say we have models for Team and Player. Assume: -Each
I have some basic questions about core data (which I am new to) and
I have a core data model with blog groups, blogs, and posts. A blog
Been following the Core Data tutorial on Apple's developer site , and all is
So, I'm trying to use Doctrine to retrieve some data. I have some basic
Using Core Data w/a sqlite store on iPhone.... I've got a bunch of comic
I'm using Core data and region monitoring. The only way to distinguish between monitored
I've got a core data app with 2 views. The first view lists Rooms,
I'm developing an app that uses Core Data for save and retrieve data. Now

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.