I have a variable, editForm, that is used as a pointer to a view controller. Later on, I use a delegate method to release editForm when the user taps the button to close the view.
@implementation EditViewController
EditFormViewController *editForm;
[...]
(void)openeditform:(NSString*)editId {
editForm = [[EditFormViewController alloc] initWithNibName:@"EditFormView" bundle:nil editId:editId];
[...]
The problem is, the view will often need to be recreated with a fresh slate. Is there a way to release the controller while keeping the empty pointer ready for future instantiations? Or a way to redeclare the "EditFormViewController *editForm;" statement from within a method?
Edit, here's the full openeditform method:
- (void)openeditform:(NSString*)editId {
EditFormViewController* editFormController = [[EditFormViewController alloc] initWithNibName:@"EditFormView" bundle:nil editId:editId];
[editFormController.view setFrame:CGRectMake(0, 0, 640, 460)];
[self.view addSubview:editFormController.view];
editFormController.delegate = self;
[UIView beginAnimations:@"editform view open" context:nil];
[UIView setAnimationDuration:0.5];
[UIView setAnimationCurve:UIViewAnimationCurveEaseOut];
[UIView setAnimationTransition:UIViewAnimationTransitionCurlDown forView:self.view.superview cache:YES];
[editFormController.view setFrame:CGRectMake(0, 0, 320, 460)];
[UIView commitAnimations];
self.editForm = editFormController;
[editFormController release];
}
For Jerry Jones, here are the bits relevant to the removal of the view.
EditFormViewController.m:
- (void) closeEditForm {
[UIView beginAnimations:@"editform view close" context:nil];
[UIView setAnimationDuration:0.5];
[UIView setAnimationCurve:UIViewAnimationCurveEaseOut];
[UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:self.view.superview cache:YES];
//[UIView setAnimationDelegate:self];
[self.view removeFromSuperview];
AppDelegate *appDelegate = [[UIApplication sharedApplication] delegate];
[appDelegate reloadEditViewTable];
[UIView commitAnimations];
[delegate didDismissEditFormView];
}
And the delegate method, which is currently not being used for anything, since I implemented Estarriol's suggestion, which isn't fully doing what I want it to do yet:
- (void)didDismissEditFormView {
NSLog(@"Fired delegate.");
//[editForm release];
}