Tengo dos entidades: ít y Nota.
asignar la relación cuando guardo
Item *item = [NSEntityDescription insertNewObjectForEntityForName:@"Item"
inManagedObjectContext:self.managedObjectContext];
Note *note = [NSEntityDescription insertNewObjectForEntityForName:@"Note"
inManagedObjectContext:self.managedObjectContext];
note.noteText = @"test";
[note setInItem:item]; //set relationship??
[self.managedObjectContext save:nil]; // write to database
Cuando cargo los datos, se cargan los atributos del elemento, pero no sé cómo cargar el note.noteText para este elemento.
self.itemNameTextField.text = self.item.name;
...
...
self.itemNoteTextField.text = ????????????
¡Gracias!
Respuestas
1 para la respuesta № 1Si item
es un ít objeto entonces item.containNote
es el conjunto de todo lo relacionado Nota objetos. Puedes iterar sobre las notas con
for (Note *note in item.containNote) {
NSString *text = note.Text;
// Now you can create a text field for this note and display the text ...
}