I have a subclass of UITableViewCell that loads a nib on the parent ViewController viewDidLoad event - where the table view is located. There's a UITextView inside this UITableViewCell. The idea is that the user enters text in this textView, and when a button is pressed it will save this text (answers for a questionnaire) in NSUserDefaults.
My problem is that I cannot read the text from the textviews. When the user enters text and the table view is scrolled up and down, I can see the text is kept, so it must be stored in memory somewhere, this happens in cellForRowAtIndexPath. For gathering the text I call this same method but the returned cell is nil. So it seems the text is kept when scrolling but if the method is called programmatically the cell is not returned. I'm not sure how to keep track of this text, I have also tried the method didEndDisplayingCell but sometimes it doesn't get called so it's not reliable.
Nib registration:
UINib *nib = [UINib nibWithNibName:@"QuestionCell" bundle:nil];
[[self tableViewOutlet] registerNib:nib forCellReuseIdentifier:cellIdentifier];
cellForRowAtIndexPath:
QuestionCell *cell = [tableViewOutlet dequeueReusableCellWithIdentifier:cellIdentifier];
if (!cell.indexPath){
cell.indexPath = indexPath;//Setup cell ...
Trying to get the text inside the textView inside the cell (returns nil if not visible):
QuestionCell *cell = (QuestionCell *)[tableViewOutlet cellForRowAtIndexPath:[NSIndexPath indexPathForRow:i inSection:0]];