KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
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? - (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; } In Swift it may also display the error: Cannot assign to property: 'textLabel' is a get-only property
Tags (comma-separated)
Save Edits
Cancel