Try This:
- (void) alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
Lists *lists = [NSEntityDescription insertNewObjectForEntityForName:@"Lists" inManagedObjectContext:_managedObjectContext];
if (buttonIndex != 0 && alertView.tag == 2) {
NSString *name = [alertView textFieldAtIndex:0].text;
UITextField *tf = [alertView textFieldAtIndex:0];
list.name =tf.text;
}
{
NSError *error = nil;
if (![_managedObjectContext save:&error]){
Handle;
}
}
}