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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T05:08:43+00:00 2026-06-13T05:08:43+00:00

How to correctly configure CoreData datamodel and NSManagedObjects for a to-many relationship? I feel

  • 0

How to correctly configure CoreData datamodel and NSManagedObjects for a to-many relationship?
I feel i have misconfigured the xcdatamodeld file, but I can’t find what’s wrong.
I generated a new single view project with CoreData selected. The following code is a simple as I can explain the problem.

Parent *parent = [NSEntityDescription insertNewObjectForEntityForName:@"Parent"      inManagedObjectContext:[self managedObjectContext]];

Child *child = [NSEntityDescription insertNewObjectForEntityForName:@"Child" inManagedObjectContext:[self managedObjectContext]];    

child.parent = parent;

When i call

[parent.children count];

Terminating app due to uncaught exception ‘NSInvalidArgumentException’, reason: ‘-[Child count]: unrecognized selector sent to instance 0x7450370’

When I call

NSMutableSet *children = [parent mutableSetValueForKey:@"children"];

‘NSManagedObjects of entity ‘Parent’ do not support -mutableSetValueForKey: for the property ‘children”

Also, there doesn’t seem to be any generated add/remove methods being generated to modify the children collection such as

- (void)addChildObject:(Child *)value;
- (void)removeChildObject:(Child *)value;

xcdatamodeld

Entities

  • Child
    relationship: parent
    destination: Parent
    inverse: children

  • Parent
    relationship: children
    destination: Child
    inverse: parent

  • Configurations (Default)
    entity: Child
    class: Child

    entity: Parent
    class: Parent

Parent.h

@interface Parent : NSManagedObject
  @property (nonatomic, retain) NSSet *children;
@end

Parent.m

@implementation Parent
  @dynamic children;
@end

Child.h

@interface Child : NSManagedObject
  @property (nonatomic, retain) NSManagedObject *parent;
@end

Child.m

@implementation Child
  @dynamic parent;
@end
  • 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-13T05:08:44+00:00Added an answer on June 13, 2026 at 5:08 am

    You should use “Editor -> Create NSManagedObject Subclass…” in Xcode to create the managed object subclass files. This ensures that you have the correct accessor functions. Another advantage is that Xcode then knows the accessor functions and does autocompletion.

    Make also sure that the children relationship is defined as “To-Many Relationship” in the Core Data Inspector.

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

Sidebar

Related Questions

Maybe I'm not searching correctly, but I can't find out how to configure the
Pretty simple problem but I just can't seem to configure this correctly. I would
I am playing with star rating plugin, but I can't configure it correctly, to
I'm trying to configure my application in facebook but I have a trouble. My
I am really lost trying to configure FOSOAuthServerBundle. I think I have correctly installed
In my project I have made configure.ac and Makefile.am files correctly so my components
Currently suppose xyz.com executes webapp ROOT. How can I configure my tomcat; so that
I'm currently setting up CI for my project and have team city configure and
Is it possible to configure PHP sessions to never expire? I currently have the
I have implemented correctly bump's api, and added this code: - (void) configureBump {

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.