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?
Your assumptions are correct. Use
didReceiveMemoryWarning.