How to set a reference from one object to another?
- by Tzur Gazit
Hi,
Imagine the obvious model of employees and departments, where each employee must refer to a single department, and each department may have none to many employees.
For Employee I have a pointer to Department, and I set its value to the address of the object of the relevant Department.
When I try to save the Employee I get an error:
2010-04-07 10:05:22.491 CoreData2[1112:207] * Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '* -[NSCFDictionary setObject:forKey:]: attempt to insert nil value (key: Department)'
I tried, just for testing, to make the reference from Employee to Department optional, but I get the same result.
I'm having my first steps in CoreData so please be as clear and simple as you can.
Thanks,
Tzur.