Main Menu
Lecture 1
Lecture 2
Lecture 3
Lecture 4
Lecture 6
Lecture 7
 

 

 

Accessing to-one relationships

public void setStore(Store value) {
    takeStoredValueForKey(value, "store");
}
 
public Store store() {
    return storedValueForKey("store");
}

Used to take a column from a database and store it in an EOContext

EOF automatically determines method names from names of variables - So you must follow naming conventions

to-one - variable has the same name as the relationship

setVar() - used to change the variable, and hence update the relationship

var() - same name as relationship - used to query the variable

Accessing to-many relationships

public void addToClients(Client object) {
//add an object to the array
   includeObjectIntoPropertyWithKey(object, "students");
}
 
public void removeFromClients(Client object) {
//remove an object from the array
   excludeObjectFromPropertyWithKey(object, "students");
}

public void setClients(NSArray array) {...} //sets whole array

public NSArray clients() {...} //gets whole array

The variable corresponding to the relatonship refers to an array of objects

Variable has the same name as the relationship

so does the method that returns the array

add and remove methods are used to add objects to and remove from the array