Core Data abstract entities broken in Xcode 8 beta 4
| Originator: | jesse.d.squires | ||
| Number: | rdar://27740937 | Date Originated: | 07-Aug-2016 |
| Status: | Open | Resolved: | |
| Product: | Xcode | Product Version: | Version 8.0 beta 4 (8S188o) |
| Classification: | Serious bug | Reproducible: | Always |
Summary:
In CoreData, when you setup a parent-child entity relationship — an abstract entity and an entity with a parent — then custom initializers on the *child* entity return an instance of the abstract, parent entity.
For example, suppose you have the following:
```
class Person: NSManagedObject { }
class Employee: Person { }
```
A custom initializer on Employee will incorrectly initialize and return a Person instance.
Steps to Reproduce:
1. Download the example project here: https://github.com/jessesquires/JSQCoreDataKit/tree/radar
2. Make sure you checkout the `radar` branch.
3. Run the unit tests for the ExampleApp target. Specifically, this test:
https://github.com/jessesquires/JSQCoreDataKit/blob/radar/Example/ExampleAppTests/ExampleAppTests.swift#L49-L62
4. Note the exception produced:
failed: caught "NSInvalidArgumentException", "-[ExampleModel.Person setSalary:]: unrecognized selector sent to instance"
Expected Results:
No exception is throw. A valid `Employee` instance is created, not an abstract `Person` instance.
Actual Results:
An exception is thrown:
failed: caught "NSInvalidArgumentException", "-[ExampleModel.Person setSalary:]: unrecognized selector sent to instance"
Because an abstract `Person` instance is initialized, not a (child) `Employee` instance.
Version:
Version 8.0 beta 4 (8S188o)
Notes:
Configuration:
Attachments:
Comments
Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!