0
I noticed a problem with the code, when I try to insert a new record in an entity, I lose all the old records and only the new one is saved.
Code used:
NSManagedObjectContext * context = [self managedObjectContext];
NSManagedObjectContext * novoObjeto = [NSEntityDescription insertNewObjectForEntityForName: entidadeBebidas inManagedObjectContext: context];
[novoObjeto setValue: novoValor forKey: @ "id"];
NSError * error = nil;
if (![context save: & error]) {
//[self alertaErroCadastro];
//NSLog(@"Erro ao salvar no banco local");
}
Before insertion:
| id |
12542
12542
25412
21452
After inserting the new record:
| id |
998698
Previous records are lost.
I played here and the insertion worked smoothly, you could post more details?
– fpg1503
Well I’m using this code inside a looping
for
– Tiago Amaral
Tried to change the type of new
NSManagedObject
?– fpg1503
Thanks for the suggestion... I’ll test now and I’ll tell you if it worked...
– Tiago Amaral