views:

129

answers:

1

I'm stumped (and likely blind to something incredibly obvious). I have a UITableView, which I want to do terribly normal things with, such as display text in each row. To do this, I've implemented the usual delegate method tableView:cellForRowAtIndexPath:. This is called as expected. According to the docs, I'm supposed to create a UILabel object and set it as the textLabel property on the new UITableCell. But I crash with unrecognized selector for setTextLabel:-- the compiler duly Warns me as well that it's not there. The deprecated method setText: is present and works fine (with warning). I definitely seem to building against the 3.0 libraries (I don't get a choice in the dropdown of other targets. So I'm puzzled. What am I missing?

Thanks.

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    UITableViewCell * cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:nil] autorelease];
    UILabel * label = [[[UILabel alloc] init] autorelease];
    [label setText:@"Foo."];
    [cell setTextLabel:label];   // BOOM.
    return cell;
}
+4  A: 

The textLabel property ist marked readonly. You had to use.

cell.textLabel.text = @"some Text";

AlexVogel
D'oh. Thanks...
quixoto