Cintu
Cintu

Reputation: 913

I got Error while using UITableView as 'setText:' is deprecated

I got Error while using UITableView as 'setText:' is deprecated in line cell.text=cellvalue Please anyone can how to fix this?

- (UITableViewCell *)tableView:(UITableView *)atable cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    static NSString *CellIdentifier = @"Cell";
    UITableViewCell *cell = [atable dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier] autorelease];
    }
    NSString *cellValue = [listOfItems objectAtIndex:indexPath.row];

    cell.text = cellValue; //Error 'setText:' is deprecated 

    return cell;
}

Upvotes: 0

Views: 1067

Answers (2)

Evan Mulawski
Evan Mulawski

Reputation: 55334

Because Apple added the Subtitle style to the table view cells, you need to use:

[cell.textLabel setText:@"String"];

instead.

Upvotes: 0

knuku
knuku

Reputation: 6102

cell.textLabel.text = @"Value"

Upvotes: 3

Related Questions