I've got a simple application with two entities:
Person:
Attributes:
name
Relationships:
nativeLanguage: (<<-> Language.natives)
nonNativeLanguage: (<<-> Language.nonNatives)
Language:
Attributes:
name
Relationships:
natives: (<->> Person.nativeLanguage)
nonNatives: (<->> Person.nonNativeLanguage)
On the edit screen for people, I've got a table display set to list the non-native languages listed for the person, along with a drop box for them to choose another language and a button to add the new language to the list.
My goal is to create a function as follows:
- (IBAction)addNonNativeLanguage:(id)sender {
// tack the language to the end of the list on a many-many relationship
PersonEntry.nonNativeLanaguages = PersonEntry.nonNativeLanguages + sender;
}
and attach the action to the button. Trick is, while I know how to assign and modify regular variables, I have no idea how to modify the contents of Core Data outside of Interface Builder. How can I do it in Objective-C?