Note that there are some explanatory texts on larger screens.

plurals
  1. PORelease controller, but keep empty pointer?
    primarykey
    data
    text
    <p>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.</p> <pre><code>@implementation EditViewController EditFormViewController *editForm; [...] (void)openeditform:(NSString*)editId { editForm = [[EditFormViewController alloc] initWithNibName:@"EditFormView" bundle:nil editId:editId]; [...] </code></pre> <p>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?</p> <p>Edit, here's the full openeditform method:</p> <pre><code>- (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]; } </code></pre> <p>For Jerry Jones, here are the bits relevant to the removal of the view.</p> <p>EditFormViewController.m:</p> <pre><code>- (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]; } </code></pre> <p>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:</p> <pre><code>- (void)didDismissEditFormView { NSLog(@"Fired delegate."); //[editForm release]; } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload