tags:

views:

13

answers:

1

I have a basic view with a UITextField and a Tableview. I am able to enter text to the TextView and capture the value through an IBOutlet and IBAction.

My IBAction is setMyNote within which I call the cellForRow... method.

In my cellForRow.. method I have this snippet code

static NSString *CellIdentifier = @"Cell";

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
    cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}

NSString *enNote = [[NSString alloc] initWithString:enteredNote.text];

NSInteger nRow = [indexPath row];
switch (nRow) {
    case 1:
        cell.textLabel.text = enNote;
        break;
    default:
        break;
}
[enNote release];
return cell;

}

When I run my debugger, I can see that enNote has the new text I entered on the textView and it seems to get assigned to my cell.textLabel.text too -- but my table does not show this new text. What am I missing?

+1  A: 

You shouldn't call the cellForRow directly.

When the table view renders itself it calls the cellForRow method in order to create the cells that should be visible.

I think that you should update your table view data source instead of trying to update the cell directly and then reload the table view ([tableView reloadData];).

Michael Kessler
Thanks! that got rid of a warning I was getting and couldn't make sense of. Now I have my [rootTableView reloadData]; But where do I set the NSIndexPath for it? Because I get a EXC_BAD_ACCESS errorIn my code the rootTableView is a IBOutlet in the main UIViewController.
John
I see that you haven't read any documentation/tutorial about working with table views. There are plenty of tutorials on the web. There are Apple's sample projects that show you how to work with table views. There is no reason to come here (stackoverflow) before you know the basics...
Michael Kessler