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

  • Home
  • SEARCH
  • 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 6608015
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T19:33:54+00:00 2026-05-25T19:33:54+00:00

I have the following entities: User . The common user entity with username, mail,

  • 0

I have the following entities:

  • User. The common user entity with username, mail, etc.
  • ComputerUserWithAI. Similar to user but it’s controlled by the application.
  • Pick. Contains a relation to Game and it should hold a picker.

Since a Picker can be an User or a ComputerUserWithAI I created an Abstract Entity called Picker and I made User and ComputerWithAI extend that Picker class.
Once I added the Picker entity I made Pick have a relation to the Picker entity called picker.

Everything went fine, but I can’t insert a ComputerUserWithAI to a Pick. My code is like this:

ComputerUserWithAI *userWithAI = [NSEntityDescription insertNewObjectForEntityForName:@"ComputerUserWithAI" inManagedObjectContext:ctx];
userWithAI.name = @"DeepBlue";

Pick *pick = [NSEntityDescription insertNewObjectForEntityForName:@"Pick" inManagedObjectContext:ctx];
pick.game = game;
pick.picker = userWithAI;

The error I get is the following:

Terminating app due to uncaught exception
‘NSInvalidArgumentException’, reason: ‘Unacceptable type of value for
to-one relationship: property = “picker”; desired type = Picker; given
type = NSManagedObject; value = (entity:
ComputerUserWithAI…

But when I do:

pick.picker = [NSEntityDescription insertNewObjectForEntityForName:@"Picker" inManagedObjectContext:ctx];

it does work.

I checked the generated classes from core data and they are extending the Abstract Entity correctly. What might be wrong?

  • 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-25T19:33:55+00:00Added an answer on May 25, 2026 at 7:33 pm

    Found the error. The generated Pick.h had the following:

    @class Picker
    @interface Pick : NSManagedObject
    
    @property (nonatomic, retain) NSManagedObject *game;
    @property (nonatomic, retain) Picker *picker;
    

    Changing it to:

    @interface Pick : NSManagedObject
    
    @property (nonatomic, retain) NSManagedObject *game;
    @property (nonatomic, retain) NSManagedObject *picker;
    

    made everything work.

    Try verifying the code generated by Xcode. This happened to me using Xcode 4.2.

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

Sidebar

Related Questions

I have the following two entities: @Entity class Relation{ @ManyToOne private User user; //some
Say, I have following entities: @Entity public class A { @Id @GeneratedValue private Long
I have the following entities: @Entity public class Owner{ @Id @Column(name = OWNER_ID) @OneToMany()
I have the following entities: public class User { public virtual ICollection<Role> Roles {
We have the following two entities with many-to-many association: @Entity public class Role {
I have following two entities public class User { [Key] public int Id {
Got three entities - User - Has username/password, contact information, billing information etc. Periodical
I have the following database tables: Table1: User UserId Username Table2: Role RoleId Rolename
My application has the following entities: public class User { public virtual int UserID
I have the following query: if (entities.User.Count(u => u.Id == ownerUserId && u.GroupId ==

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.