I'm sorry I'm a newbie of Cocoa so that I don't know if I can show
you appropriate situation, but I'll try.
An EXC_BAD_ACCESS error comes only after my app reads my custom
format type of data and reads document nib file.
1. When new document is selected, no problem.
2. When open document is selected and the app reads one of three
formats which Core Data supports, no problem.
3. Only after reading custom formatted file and after
windowControllerDidLoadNib gets called, EXC_BAD_ACCESS comes.
The windowControllerDidLoadNib method calls [super
windowControllerDidLoadNib] and detects how each attribute of
managedObjects
has been set.
It looks fine that the custom formatted data is read, and the objects
created and initialized with the data seem to be fine.
Because the value of each attribute of managedObjects was what I
expected.
This method reads a custom type of data and set all attributes of
entity "Department" using setValue:forKey method.
In this method, it creates EmployeeMO by using
insertNewObjectForEntityForName: inManagedObjectContext: and
obtains employees relationship using mutableSetValueForKey: and add
the created object to the attribute using addObject.
Of cause department attribute of the EmployeeMO object set this
department object (self) using setValue:forKey:.
This method reads a custom type of data and set all attributes of
this entity using setValue:forKey method.
The following steps are in one function.
DepartmentMO* department = nil;
for (i = 0 ; i < counter; ++i )
{
department = (DepartmentMO*)[NSEntityDescription
insertNewObjectForEntityForName:@"Department"
inManagedObjectContext:context];