![]() |
|||||||||||||||||
| |
|
|
|||||||||||||||
|
Adding an EO to a relationship //existing sales person SalesPerson sales; //create a new client Client newClient = ...; //insert client into database EOEditingContext ec = sales.editingContext(); ec.insertObject(newClient); //relate client to salesperson sales.addObjectToBothSidesOfRelatioshipWithKey(newClient, "clients"); addObjectToBothSidesOfRelatioshipWithKey performes different actions on different relationships
thus don't have to wory about whether object is one way or two way Removing EOs from a relationship //existing sales person and client SalesPerson sales; Client theClient; //remove from salesperson's relationship sales sales.removeObjectFromBothSidesOfRelatioshipWithKey(theClient, "clients"); //delete client from database EOEditingContext ec = theClient.editingContext(); ec.deleteObject(theClient); handles both one and two way relationships Lect 5 Demo 4 and 5 ( Download 4 5)
Page updated September 9, 2004 |
||||||||||||||||
|
|
|||||||||||||||||