views:

21

answers:

1

I want to programatically set a text in my UITableView. I do not want to do it from

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

I tried something like

[self.tableView cellForRowAtIndexPath:[NSIndexPath indexPathForRow:1 inSection:0]].textField.text = @"test";

This doesn't work as this is not part of the structure. How do I do it? Been looking in the docs but cannot find it.

A: 

You want to use textLabel, not textField. This is, in general, a bad idea. You should provide the proper cell in -tableView:cellForRowAtIndexPath:. If you only want to adjust one cell, you can use -[UITableView reloadRowsAtIndexPaths:withRowAnimation:].

Ben Gottlieb
You are right it is a pretty bad idea. The right approach is as suggested by aBitObvious.
munchine