Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- - (IBAction)AgregarButton:(id)sender {
- NSEntityDescription *desc = [NSEntityDescription entityForName:@"Persona" inManagedObjectContext:_context];
- NSManagedObject *agregarPersona = [[NSManagedObject alloc]initWithEntity:desc insertIntoManagedObjectContext:_context];
- UIAlertView *alerta;
- NSError *error;
- if ([_AddTextField.text isEqualToString:@""]) {
- alerta = [[UIAlertView alloc]
- initWithTitle:@"Error"
- message:@"No se puede agregar, campo de texto en blanco"
- delegate:nil
- cancelButtonTitle:@"Ok"
- otherButtonTitles:nil, nil];
- [alerta show];
- } else {
- [agregarPersona setValue:_AddTextField.text forKey:@"nombre"];
- alerta = [[UIAlertView alloc]
- initWithTitle:@"Aviso"
- message:[NSString stringWithFormat:@"Se ha agregado a: %@" , _AddTextField.text]
- delegate:nil
- cancelButtonTitle:@"Ok"
- otherButtonTitles:nil, nil];
- [alerta show];
- }
- if (![_context save:&error]) {
- NSLog(@"%@" , error.localizedDescription);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement