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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T14:55:54+00:00 2026-05-20T14:55:54+00:00

Lets say you have the classic Manager <- Department(s) ->> Employee data model. Where

  • 0

Lets say you have the classic Manager <- Department(s) ->> Employee data model. Where the Manager inherits from the Employee entity which inherits from the Person entity.

If I have a Department, with a Manager and a set of Employees, how can I programmatically represent the Manager losing their job and being demoted to just an Employee, and one of the employees being promoted to the Manager?

In Core Data parlance, I want to take a Managed Object and change its entity, although keep it as a subclass of Person. Is there a smart way to do this? Or will I have to write methods to promote an Employee and demote a Manager like this:

+ (Employee *)demoteManager:(Manager *)manager {

  // Get the context
  NSManagedObjectContext *context = [manager managedObjectContext];

  // Create a new employee object (mogenerator style)
  Employee *employee = [Employee insertIntoManageObjectContext:context];

  // Set attributes etc
  employee.name = self.name; 

  // Set relationships etc
  Department *dept = manager.manages;
  [dept addEmployeesObject:employee];
  employee.department = dept;
  dept.manager = nil;
  manager.manages = nil;

  // Delete manager
  [context deleteObject:manager];

  // Save
  NSError *error = nil;
  [context save:&error];

  return employee;
}

etc? And I realise that I should just put a boolean flag on Employee (isManager), but this is a contrived example for this question, in reality I don’t want to use a flag.

So, if some Core Data wizards have done this already or know a better way, I’d love to hear!

Cheers,

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

    There is no way to change an entity like you are describing. You would need to create a new employee, copy the manager’s data to that employee record and create a new manager for the promoted employee.

    However, as Christian suggested, it would be better if your manager was also an employee. You mentioned additional data that is manager specific. Perhaps you could put this into a third table that has a relationship to a specific employee. Then any employee that is also a manager will have data stored in this auxiliary table. Far less painful than destroying and creating objects just to promote or demote a manager.

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

Sidebar

Related Questions

Lets say I have an Illustration entity which is an aggregate root. That entity
Lets say we have a table here, populated with the following data: acc_id1 acc_id2
Lets say I have multiple commands like 5000 which updates some column and row
Lets say i have vector of vectors vector< vector<int> > bigTable; vector<int> data; data.resize(2);
I have two objects that are derived from same the base class. Lets say
have You ever tried to import classic c++/make project into QtCreator ? Lets say
Lets say I have a class as follows: case class Person( name:String, age:Int, dependents:List[Person]
Lets say have this immutable record type: public class Record { public Record(int x,
Lets say I have five tables named table1, table2 ... table5. I have already
Lets Say i have a table like this WEB_LIST_TABLE KEY Value ---------------------------------------- 134 google.com

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.