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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T00:49:31+00:00 2026-05-14T00:49:31+00:00

I have two tables related: DataEntered and Model DataEntered -currentModel Model One DataEntered can

  • 0

I have two tables related: DataEntered and Model

DataEntered
-currentModel

Model

One DataEntered can have only ONE Model, but a Model can stay into many DataEntered.

The relationship is from DataEntered to Model (No To Many-relathionship) and no inverse relation.

XCode generates the setters for DataEnteredModel:

@property (nonatomic, retain) NSSet * current_model;

- (void)addCurrent_modelObject:(CarModel *)value;
- (void)addCurrent_model:(NSSet *)value;

I have a Table and when I select a model, I want to store it to DataEntered:

Model *model = [fetchedResultsController objectAtIndexPath:indexPath];
NSLog(@"Model %@",model.name); // ==> gives me the correct model name
[dataEntered addCurrent_modelObject:model]; // ==> always nil
[dataEntered setCurrent_model:[fetchedResultsController objectAtIndexPath:indexPath]]; // the same, always nil

what I’m doing wrong ?????

thanks,

r.

edit:

You’re right, first I had a to-many relationship, and XCode generated the entity code, that’s why after changed the relathionship it still was set as a SET.

Now I’ve re-generated the entity, and now I have the property like this:

@property (nonatomic, retain) CarModel * current_car_model;

But I’m still getting the same problem.

Now, I’ve added the inverse relathionship and re-generated the entities. Both entities hav a TO-One relationship. Still having the same problem.

Ok, another try: The relathionship from model to DataEntered is now To-Many. The entites are regenerated again, and now the model is assigned with:

Model *model = [fetchedResultsController objectAtIndexPath:indexPath];

[dataEntered addCurrent_modelObject:model];

And the very last, both relathions are to-many. The same problem exists.

But what I don’t understand is why I have to have an inverse relation in this case.

To resume: how I have to define my relations in this case ?

DataEntered can have only ONE Model.

Each Model can be related into many DataEntered.

In an SQL database definition, a field with the id of the model stored in a simple longint field in the DataEntered would be enough. When the relathion is to-many I can’t see the field in the .sqlite database, now that I’ve changed again into To-One, I can see the current_model field as integer. But again, I have in the Model table a field with the related DataEntered, and I think this is wrong, as I’m not going to store Nothing here.

Any light would be appreciated …

🙂

thanks …..

r.

  • 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-14T00:49:31+00:00Added an answer on May 14, 2026 at 12:49 am

    If your attribute is created as a set, then you don’t have it set as a to-one relationship but a to-many. So this:

    @property (nonatomic, retain) NSSet * current_model;
    

    …indicates a to-many relationship.

    If your model entity has a relationship to the DataEntered entity but you haven’t set the same reciprocal relationship you can expect problem.

    Edit:

    I think you’re major problem is that you’re thinking of Core Data as a form of SQL, which it is not. Entities are not tables. Objects are not records. Core Data is an object graph and an object graph is much different than SQL. For one thing, it is possible to have an orphaned object in Core Data but you can’t really lose a record in SQL. That is why Core Data really wants reciprocal relationships.

    Instead of thinking in SQL terms, you should think of it as if you were creating an object graph from scratch without Core Data. How would you handle it if you just wrote a DataEntered class and a model class yourself from scratch? How would you manually relate them. Looking at it from that perspective makes Core Data easier to understand.

    I would offer that your choice of entity names might cause problems. It looks like you model entity is actually named “_model”. Apple reserves symbols beginning with an underscore and “model” of course could easily show up internally in Core Data so you might be having a name collision. Try changing the name to something like “CarModel” if you like underscores, change it to “CarModel_”.

    Also, the “DataEntered” entity/class seems poorly named. “Data Entered” is an action not an object. The entity/class should represent some physical or data object. For example, “CustomerCar” would be a entity/class that models a car which in turn would have a “model” relationship to a “CarModel” entity/class.

    It is very, very hard to debug Core Data with just a textual description of the object graph especially, (no offense) when the person describing the graph is a novice. It would help if you could take a screen shot of the data model editor and post that so we can see it.

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

Sidebar

Ask A Question

Stats

  • Questions 378k
  • Answers 378k
  • 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 Assuming that you are fine losing those changes then that… May 14, 2026 at 9:11 pm
  • Editorial Team
    Editorial Team added an answer Click on the "show details" link under Date (dd/mm/YYY), then… May 14, 2026 at 9:11 pm
  • Editorial Team
    Editorial Team added an answer Note that you are echoing and in false condition it… May 14, 2026 at 9:11 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

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.