D
D
Dmitry2015-10-30 15:37:11
Objective-C
Dmitry, 2015-10-30 15:37:11

How to inherit attribute value of parent Entity?

There are two non-abstract Entities, one is specified by the parent of the second. We create an object of the parent Entity and set the values ​​to the attributes. Then we create an object of the child Entity. How to pass parent object attribute values ​​to child object?

Car *car = [NSEntityDescription insertNewObjectForEntityForName:@"Car"
                 inManagedObjectContext:dataManager.managedObjectContext];
car.mark = @"Opel";
car.model = @"Zafira";
        
ClientCar *clientCar = [NSEntityDescription insertNewObjectForEntityForName:@"ClientCar"
                                   inManagedObjectContext:dataManager.managedObjectContext];
//Хочу что сделать что то подобное
clientCar = (ClientCar *)car;
clientCar.date = [NSDate date];

//Или как то так, но не думаю что это верное решение
clientCar.mark = car.mark;
clientCar.model = car.model;
clientCar.date = [NSDate date];

Answer the question

In order to leave comments, you need to log in

1 answer(s)
O
one pavel, 2015-10-30
@onepavel

If I understand correctly, your parent and child are represented at the class level. And you use objects that are not related to each other. I see only the second option so far.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question