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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T20:37:51+00:00 2026-06-10T20:37:51+00:00

I have a Core Data model similar to this: When a Webgallery or Article

  • 0

I have a Core Data model similar to this:

enter image description here

When a Webgallery or Article object gets saved, it may use one or many pictures. They can use the same photographical subject but maybe in different sizes. I don’t save pictures that don’t get used in either a WebGallery or an Article.

Picture‘s relationships instance and social are set to cascade, so when the Picture object gets deleted, the corresponding PictureInstance and Social objects get deleted too.

1) Is there any way to know when a picture doesn’t get used anymore, neither by WebGallery nor by Article so it can be deleted?

2) Is it a problem that the relationships previewPicture and teaserPicture don’t have an inverse?

  • 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-06-10T20:37:52+00:00Added an answer on June 10, 2026 at 8:37 pm

    You should have an inverse for the relationship. With the inverse, the question becomes trivial. When a simple cascade rule will delete them from WebGallery and Article. (or perhaps you just want to nullify).

    You should typically model relationships in both directions, and specify the inverse relationships appropriately. Core Data uses this information to ensure the consistency of the object graph if a change is made (see “Manipulating Relationships and Object Graph Integrity”). For a discussion of some of the reasons why you might want to not model a relationship in both directions, and some of the problems that might arise if you don’t, see “Unidirectional Relationships.”

    (Core Data Programming Guide)

    You can simply check if a picture is used whenever you delete it from a gallery or article:

    ;
    if (pictureToRemove.galleries.count == 0 && pictureToRemove.articles.count == 0) {
        [managedObjectContext deleteObject:pictureToRemove];
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Core Data model similar to this: Company Entity companyName attribute (string)
Lets say I have a core data model like this one: Item attributes: name
I have core data model with two entities that have a many-to-many relationship with
I have this Core Data Model Hierarchy, with the respective relationships to each other:
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 basic Core data model like this: Class -Class Name (string) Relationship:
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.
I have several Core Data model version that I have added to my .xcdatamodeld

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.