Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

John Baughman

macrumors regular
Original poster
Oct 27, 2003
100
0
I am working through chapter 30 in Hillegass' book and have the core data project working fine, but do not understand how bindings do their trick. Here is a summary of the project as presented in the book.

We created a Core Data Document-Based Application. The MyDocument.xib to be used to swap out Department and Employee views...

1. Created a class of type NSViewController named ManagingViewcontroller and declared an NSManagedObjectContext object named managedObjectController.

2. Created 2 subclasses to managedObjectController, DepartmentViewController and EmployeeViewController

3. Created 2 new XIB files, DepartmentView and EmployeeView, with their File's Owner class set to DepartmentViewController and EmployeeViewController respectfully. These custom views to be used in the Mydocument.xib do display their respective data.

4. Created 2 entities, Department and Employee, in the the xdatamodel. Department was given one field deptName plus some related fields to Employees.

5. Created Managed Object Classes for the 2 entities Department and Employee.

6. In the Department managed object we have the variable deptName declared with @property (Department.h) and @dynamic (Department.m).

7. In the Department XIB we added 2 array controllers, Depts and EmployeeList, to display the Department and Employee entity's data.

8. In the custom view in the Department XIB we added table views to display the Department and Employee data.

9. We then made the following bindings...

Depts Array Controller Managed Object Context -> File's Owner
Departments Column (tv) Value -> Depts AC - Key Path -> deptName

What I am having trouble seeing is how the Depts Array Controller finds the deptName attribute when the view is loaded or finds the Department entity when adding or removing rows. I am thinking it should be..

TableColum (deptName) -> Dept AC -> File's Owner (Managed Object Context) -> DepartmentViewController -> ManagingViewController -> ???

I don't get there. I obviously still do not have handle on how the model connects to the controllers.

I'm probably not asking my question correctly. I am looking for a path from the Dept AC to the data which I think must be a path to the Managed Object Class Depatrment.h where deptName is declared

Same question with regard to adding or deleting. The add and delete buttons both have sent actions to Depts AC add and delete, which also lead me to dead ends.

Another question. We set the Delete button Enabled binding to the Depts AC canRemove controller key. The Add button doesn't have any bindings. Why was this necessary for the Delete button but not something similar for the Add button?

Hope I made my question clear enough for someone to help me understand how this is all working.

Thanks,

John
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.