Sto utilizzando CoreData con iPhone SDK. Sto facendo un'app per appunti. Ho una tabella con gli oggetti nota visualizzati dal mio modello. Quando si preme un pulsante, voglio salvare il testo nella vista testo sull'oggetto che si sta modificando. Come faccio a fare questo? Ho provato diverse cose ma nessuna sembra funzionare.Salva oggetto in CoreData
Grazie
EDIT:
NSManagedObjectContext *context = [fetchedResultsController managedObjectContext];
NSEntityDescription *entity = [[fetchedResultsController fetchRequest] entity];
NSManagedObject *newManagedObject = [NSEntityDescription insertNewObjectForEntityForName:[entity name] inManagedObjectContext:context];
[newManagedObject setValue:detailViewController.textView.text forKey:@"noteText"];
NSError *error;
if (![context save:&error]) {
/*
Replace this implementation with code to handle the error appropriately.
abort() causes the application to generate a crash log and terminate. You should not use this function in a shipping application, although it may be useful during development. If it is not possible to recover from the error, display an alert panel that instructs the user to quit the application by pressing the Home button.
*/
NSLog(@"Unresolved error %@, %@", error, [error userInfo]);
abort();
}
Il codice precedente salva correttamente ma lo salva come un nuovo oggetto. Voglio che venga salvato come quello che ho selezionato nel mio TableView.
Grazie, in realtà ha appena funzionato. Ho dovuto modificarlo un po 'perché sto lavorando con l'iPad ma fondamentalmente lo stesso codice. Grazie – John