如何让我的应用程序在关闭时存储信息。因为每次我重新打开它,所有的核心数据都会被删除。
这是一个例子:
NSString *nomville = [[_jsonDict objectAtIndex:indexPath.row] objectForKey:@"label"];
NSString *idVille = [[_jsonDict objectAtIndex:indexPath.row] objectForKey:@"id"];
detailView.title = nomville;
detailView.idVille = idVille;
NSLog(@"Valor: %@", nomville);
NSLog(@"Valor: %@", idVille);
AppDelegate *appDelegate = [[UIApplication sharedApplication] delegate];
NSManagedObjectContext *context = [appDelegate managedObjectContext];
NSManagedObject *villesR = [NSEntityDescription
insertNewObjectForEntityForName:@"Ville"
inManagedObjectContext:context];
[villesR setValue:idVille forKey:@"idV"];
[villesR setValue:nomville forKey:@"nom"];
[self.navigationController pushViewController:detailView animated:YES];