How to set a reference from one object to another?
Posted
by Tzur Gazit
on Stack Overflow
See other posts from Stack Overflow
or by Tzur Gazit
Published on 2010-04-07T07:13:40Z
Indexed on
2010/04/07
7:23 UTC
Read the original article
Hit count: 308
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.
© Stack Overflow or respective owner