1

For a UIViewController, in case its view is unloaded, I want to save (to an NSString ivar) the text string that a user has entered into a UITextView (or UITextField).

Where should I do this?

I'm assuming the UITextView will already have been reset to nil in viewDidUnload, correct?

So, I want to do something like this:

- (void)viewWillUnload {
    UITableViewCell *cell = [self.tableView cellForRowAtIndexPath:
                             [NSIndexPath indexPathForRow:2 inSection:0]];
    UITextView *textView = (UITextView *)[cell viewWithTag:TEXT_VIEW_TAG];
    self.stringIvar = textView.text;
    [super viewWillUnload];
}

But what's the viewWillUnload method? Is it didReceiveMemoryWarning?

ma11hew28
  • 121,420
  • 116
  • 450
  • 651
  • No, `viewWillUnload` is `viewWillUnload`, not another method... – jv42 Jul 27 '11 at 14:22
  • @jv42, `viewWillUnload` is a method name I made up. It doesn't exist. `didReceiveMemoryWarning` (which tries to unload the view) is always called before `viewDidUnload`, ergo treat `didReceiveMemoryWarning` as if it were called `viewWillUnload`. – ma11hew28 Aug 01 '11 at 09:19
  • ok... This wasn't clear at all to me, maybe you could rephrase it a bit, or it's just because I hadn't my nose in a UIVC at the time I read. – jv42 Aug 01 '11 at 10:12

1 Answers1

0

Your assumptions are correct. Use didReceiveMemoryWarning.

ma11hew28
  • 121,420
  • 116
  • 450
  • 651